dorosh / gdata-python-client

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

Move AddAllElementsFromAllPages() and GetGeneratorFromLinkFinder() to GDataService #325

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Both PropertyService and AppsService have identical implementations of 
AddAllElementsFromAllPages, and other services that inherit from 
PropertyService (e.g. GroupsService) don't have the advantage of a method 
for getting a pagination generator. Since neither methods depend on class 
functionality outside of GDataService, I propose moving them into the 
superclass rather than re-writing across the children as needed.

Patch attached.

Original issue reported on code.google.com by apro...@google.com on 13 Jan 2010 at 7:53

Attachments:

GoogleCodeExporter commented 9 years ago
I personally find GetGeneratorFromLinkFinder more appealing than 
AddAllElementsFromAllPages. It seems like combining entries into the original 
feed 
could hide information that you might be interested in from the second, third, 
fourth, feed objects which are retrieved. The feed object would still have a 
next 
link which points to "page 2" even though the entries for the second page are 
now in 
the feed.

Original comment by jscud.w...@gmail.com on 14 Jan 2010 at 12:16

GoogleCodeExporter commented 9 years ago
I agree in principle, and indeed this is intended to lay the groundwork for 
letting 
groups.service.GroupsService use GetGeneratorFromLinkFinder, but 
AddAllElementsFromAllPages is already used in the existing codebase, and was 
unnecessarily twice written, so I figured I'd move both into the superclass.

Original comment by apro...@google.com on 14 Jan 2010 at 12:20

GoogleCodeExporter commented 9 years ago
Here's an alternate suggestion for AddAllElementsFromAllPages, since Python 
supports 
multiple inheritance, it would be pretty easy to create a class with this 
method and 
use it as a mixin anywhere that it is needed. (This is the approach used with 
LinkFinder, take a look in src/gdata/__init__.py).

Original comment by jscud.w...@gmail.com on 15 Jan 2010 at 5:58

GoogleCodeExporter commented 9 years ago
Hi Aprotim, just wondering what you thought of this idea. Seems like this would 
be 
something that would be good to have in the next release (going out on 
Tuesday). If 
you are tied up with other stuff I can take a stab at it but you understand the 
need 
better than I.

Original comment by jscud.w...@gmail.com on 23 Jan 2010 at 2:23

GoogleCodeExporter commented 9 years ago

Original comment by jscud.w...@gmail.com on 23 Jan 2010 at 2:24

GoogleCodeExporter commented 9 years ago
Update - remove all calls to AddAllElementsFromAllPages, replace with 
list(_GetElementGeneratorFromLinkFinder()), which will coerce the generator 
into a 
list. If you want, we can not do the coercion - I'm not sure if that can 
possibly 
break other people's code.

Leave AddAllElementsFromAllPages for backwards compatibility, but suggest we 
deprecated it.

Original comment by apro...@google.com on 26 Jan 2010 at 1:37

Attachments:

GoogleCodeExporter commented 9 years ago
Looks great! I've checked this in as revision 926.

Original comment by jscud.w...@gmail.com on 26 Jan 2010 at 6:49