I ended my post by asking about the best practice used to paginate the content of a plugin. Since I didn't get flooded by the answers I assumed that this shouldn't be different than doing it on a django app. Here it is what the fine django documentation says about this topic.
So I have decided to implement this approach, the key point here is to understand that django-cms' plugin has access to the context :
This capability lets your plugin react to the GET and POST parameters. Once I have understood this the only thing that I had to do is to use the django's Paginator on the list of feed entries.
class FeedPlugin(CMSPluginBase): [...] def render(self, context, instance, placeholder): feed = get_cached_feed(instance) if instance.paginate_by: is_paginated =True request = context['request'] [...]
As you can see in the code below there is nothing specific to django-cms there.
is_paginated =True request = context['request'] feed_page_param = "feed_%s_page" %str(instance.id) feed_paginator = Paginator(feed["entries"], instance.paginate_by) # Make sure page request is an int. If not, deliver first page. try: page = int(request.GET.get(feed_page_param, '1')) except ValueError: page = 1 # If page request (9999) is out of range, deliver last page of results. try: entries = feed_paginator.page(page) except (EmptyPage, InvalidPage): entries = feed_paginator.page(paginator.num_pages)
The complete implementation of this feature is available in the bitbucket repository of cmsplugin_feed.
I would be glad to hear from you if this implementation could be enhanced.