我想从Google API v3保存AppEngine datastore上的联系人。我想知道存储这些数据的最佳方式是什么,尤其是如果已经有一个模型的话!在
看着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()
我想每个人都有自己的想法。这很容易做到,您可以查看AE-BaseApp/Python并从Github链接中查看代码。我有一些新的代码将在不久的将来更新,其中包含对联系人模型的一些改进。(更新的代码目前由于黑客攻击而被破坏,使登录在http和https上工作here)
相关问题 更多 >
编程相关推荐