Closed iptux closed 11 years ago
Thanks for the point. Making Message class comparable is immediate. You can pass key=lambda x: x.parsed.time
to the sort function.
I should consider what service home_timeline
of SNSPocket
is to provide. Original purpose of all methods of SNSPocket
is to provide a way to batch execute corresponding methods of concrete platforms. There is no confusion with other methods, e.g. auth
will authorize all the channels; update
will update statuses on all channels; etc. Sticking to this semantic, home_timeline
of SNSPocket
invokes home_timeline
of all channels with the same arguments. In this case, the current way of returning messages is reasonable.
Although the above explains the current behaviour, the count
parameter is still misleading. Maybe a clearer description in the docstring helps. ( @uestcmy FYI. )
One reason not to mix the results of all channels, sort them and truncate to count
number of messages is that:
As to the design, I think the meaning of methods of SNSPocket
is different from that of plugins. When you pass parameters to methods of SNSPocket
, you keep in mind that it is just a proxy which will invoke corresponding methods of all channels using the same argument (or possibly differently configured default values).
After we improve the docstring, please come back to see if there is still confusion.
In the app layer, if you want home_timeline
return count
Messages sorted by time, you can
SNSPocket.home_timeline = some wrapper function
got it, thanks
More notes on home_timeline
of plugins.
The plugins only guarantee no more than count messages are returned. There can be less messages. The main reason is that this is the guarantee we get from the service providers. For example, when you retrieve renren feeds (especially for specific types), even there are enough feeds, the platform may return less than count
messages.
if more than one channel is available,
home_timeline(count)
return a MessageList containscount * channel_number
Messages, but that intent to be exactlycount
Messages only.MessageList should be sorted first and return the first
count
Messagesthis requires Message class comparable by time, more recently Status should show first