google-code-export / gdata-python-client

Automatically exported from code.google.com/p/gdata-python-client
1 stars 0 forks source link

ContactsClient.get_profiles_feed() returns only the first 60 items #498

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Call get_profiles_feed() on an instance of ContactsClient

What is the expected output? What do you see instead?

Only the first 60 items are returned instead of the whole list.

Original issue reported on code.google.com by guillaum...@gmail.com on 24 Feb 2011 at 9:39

GoogleCodeExporter commented 9 years ago
Hello Guillaume,

Have you tried checking for the existence of the "next" link?

[CODE]
  while feed:
      # Prepare for next feed iteration
      next = feed.GetNextLink()
      feed = None
      if next:
        feed = self.gd_client.GetProfilesFeed(uri=next.href)
      else:
        feed = None
[/CODE]

Best,
Alain

Original comment by ala...@google.com on 24 Feb 2011 at 9:47

GoogleCodeExporter commented 9 years ago
It's working, thanks!

However, the max-results parameter is of 60 items by default. As I would like 
to obtain all profiles (3000+ items), it would take too much time with this 
default parameter.

The ProfilesQuery should fix that (in gdata/contacts/client.py), but it is 
broken as it does not call the parent __init__function. I will submit a patch.

Original comment by guillaum...@gmail.com on 1 Mar 2011 at 3:18

GoogleCodeExporter commented 9 years ago
Not entirely tested, but I think the ProfilesQuery class should be replaced by 
this :

class ProfilesQuery(gdata.client.Query):
    def __init__(self, feed=None, **kwargs):
        gdata.client.Query.__init__(self, **kwargs)
        self.feed = feed or 'http://www.google.com/m8/feeds/profiles/default/full'

Original comment by guillaum...@gmail.com on 1 Mar 2011 at 3:27

GoogleCodeExporter commented 9 years ago
Hello Guillaume,

You're indeed right! This should be something like that:

[CODE]
class ProfilesQuery(gdata.client.Query):
    def __init__(self, feed=None, start_key=None, **kwargs):
        gdata.client.Query.__init__(self, **kwargs)
        self.start_key = start_key
    ....
[/CODE]

Additionally, you can use a standard request and pass it to the GetFeed method:

[CODE]
query = gdata.client.Query(max_results=600)
feed = gd_client.GetFeed(gd_client.GetFeedUri('profiles'),
                                              desired_class=gdata.contacts.data.ProfilesFeed,
                                              q=query)
[/CODE]

I will send a patch to correct the issue ASAP.

Best,
Alain

Original comment by ala...@google.com on 1 Mar 2011 at 4:44

GoogleCodeExporter commented 9 years ago
Merci Alain!

Original comment by guillaum...@gmail.com on 1 Mar 2011 at 11:24

GoogleCodeExporter commented 9 years ago
The changes have been submitted in the repository.

Best,
Alain

Original comment by ala...@google.com on 30 Mar 2011 at 8:57