Hi Alain,
Thanks for your reply. Your idea works. This is the code I have used:
def UpdateGroupsHashPage(self, feed, ctr):
if not feed.entry:
print '\nNo groups in feed.\n'
return 0
for i, entry in enumerate(feed.entry):
self.groups[entry.id.text] = entry
return len(feed.entry) + ctr
def UpdateGroupsHash(self):
self.groups = { }
feed = self.gd_client.GetGroupsFeed()
self.ProcessPaginatedFeed(feed, self.UpdateGroupsHashPage)
def ProcessPaginatedFeed(self, feed, process_method):
""" Process all pages of a paginated feed.
This will iterate through a paginated feed, requesting each page and
printing the entries contained therein.
Args:
feed: A gdata.contacts.ContactsFeed instance.
process_method: The method which will be used to print each page of
the
feed. Must accept these two named arguments:
feed: A gdata.contacts.ContactsFeed instance.
ctr: [int] The number of entries in this feed previously
printed. This allows continuous entry numbers when paging
through a feed.
"""
ctr = 0
while feed:
# Print contents of current feed
ctr = process_method(feed=feed, ctr=ctr)
# Prepare for next feed iteration
next = feed.GetNextLink()
feed = None
if next:
if self.PromptOperationShouldContinue():
# Another feed is available, and the user has given us permission
# to fetch it
feed = self.gd_client.GetContactsFeed(next.href)
else:
# User has asked us to terminate
feed = None
Nevertheless, I find it a bit awkward that I need to keep locally a copy of
the group information.
It seems more natural to me that it should be posible to access that
information directly from the server, using the href, but maybe I am
mistaken.
--
You received this message because you are subscribed to the Google
Groups "Google Contacts, Shared Contacts and User Profiles APIs" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://code.google.com/apis/contacts/community/forum.html