0
下面的代碼:我不能夠訪問一些的GData聯繫人屬性,如性別
def fetch_feed(self):
client = gdata.contacts.service.ContactsService()
client.ClientLogin(username, password) #Will change to AuthSub later.
query = gdata.contacts.service.ContactsQuery()
query.max_results = 3000
feed = client.GetContactsFeed(query.ToUri())
memcache.set('feed',feed, 3600)
return feed
feed = self.fetch_feed()
self.PrintFeed(feed)
def PrintFeed(self, feed):
for entry in feed.entry:
print entry.* #example... i can access properties such as entry.title, entry.id, entry.updated, but can't access a whole lot more.
什麼我做錯了什麼,或者什麼我不這樣做呢? 我在Apps API論壇上發佈了相同的問題,只是爲了澄清事情。
編輯 以下是我正在導入的內容:
from google.appengine.api import memcache, users
from google.appengine.ext import db, webapp
from google.appengine.ext.webapp import util
import atom
import atom.url
import datetime
import gdata.alt.appengine
import gdata.contacts
import gdata.contacts.client
import gdata.contacts.data
import gdata.contacts.service
import gdata.client
import gdata.service
import settings
EDIT2: 固定QRY錯字後,我得到了錯誤:
Traceback (most recent call last):
File "C:\Program Files\Google\google_appengine\google\appengine\ext\webapp\__init__.py", line 511, in __call__
handler.get(*groups)
File "C:\etrebug\main.py", line 55, in get
feed = self.fetch_feed()
File "C:\etrebug\main.py", line 67, in fetch_feed
feed = client.get_contacts(qry)
File "C:\etrebug\gdata\contacts\client.py", line 194, in get_contacts
desired_class=desired_class, **kwargs)
File "C:\etrebug\gdata\client.py", line 635, in get_feed
**kwargs)
File "C:\etrebug\gdata\client.py", line 276, in request
version=get_xml_version(self.api_version))
File "C:\etrebug\atom\core.py", line 516, in parse
return _xml_element_from_tree(tree, target_class, version)
File "C:\etrebug\atom\core.py", line 525, in _xml_element_from_tree
if target_class._qname is None:
AttributeError: 'ContactsQuery' object has no attribute '_qname'
我明白了。在我發送的這個鏈接上,它表示Python庫尚未更新到v3,但這讓我感到悲傷,但至少它說有些字段沒有公開在以前的版本中,其中unsaddens我。 http://code.google.com/intl/pt-BR/apis/contacts/docs/3.0/migration_guide.html – 2010-11-15 00:53:23
是的,整個gdata python庫尚未被移植,但當前版本的gdata確實支持這個功能。幾個月前我添加了它。 – 2010-11-15 02:24:14
它給了我一個錯誤:'ContactsQuery'對象沒有屬性'get_contacts' 我更新了我用的導入問題。 – 2010-11-15 03:05:57