用于appengine数据存储区的Google Contact的Python模型

时间:2012-06-11 22:08:09

标签: python google-app-engine database-design gdata google-contacts

我想保存AppEngine datastore Google API v3上的联系人。我想知道存储这些数据的最佳方法是什么,特别是如果已有模型的话!

the sources of gdata,我发现了一个非常有趣的开端。但这只是在python中的数据建模,而不是数据存储的建模。

问题:这个模型在python中是否已经存在?

如果不是:

问题:从头开始的最佳方式是什么?

Python中联系人的初始示例:

class Contact(db.Model):
    """
    https://developers.google.com/gdata/docs/2.0/elements?hl=fr#gdContactKind
    https://developers.google.com/appengine/docs/python/datastore/datamodeling
    """

    content = db.Text()
    """atom:content Notes about the contact."""

    link = db.ListProperty(Link,indexed=False,default=[])
    """atom:link*   Links to related information. Specifically, atom:link[@rel='alternate'] links to an HTML page describing the contact."""

    title = db.StringProperty()
    """atom:title   Contact's name. This field is read only. To modify the contact's name, see gd:name."""

    email = db.ListProperty(Email,indexed=False,default=[])
    """gd:email*    Email addresses."""

    """etc..."""

class Link(db.Model):
    """
    Link
    """
    link = db.LinkProperty()

class Email(db.Model):
    """
    Email
    """
    email_address = db.EmailProperty()


class EmailImParent(db.Model):
  address = db.StringProperty()
  label = db.StringProperty()
  rel = db.StringProperty()
  primary = db.StringProperty()


class Email(db.Model,EmailImParent):
  """
  The gd:email element.
  """
  email =  db.EmailProperty()
  display_name = db.StringProperty()

1 个答案:

答案 0 :(得分:0)

我认为每个人都在自己动手。这很容易,您可以查看AE-BaseApp/Python并查看Github链接中的代码。我有一些新代码将在不久的将来更新,其中包含对联系人模型的一些改进。 (更新的代码目前已被破解,因为黑客攻击以使http和https here都能正常工作)