Hello Christoph, hello list,
keeping in mind the warnings about the beta quality of the software, I
have tried integrating it in an existing Pyramid project.
Long story: I wanted to replace the Xapian indexer with Apache-Solr,
using the "sunburnt" module to interface Python with Solr.
With Xapian, I could retrieve all results of an index query, and feed
them into webhelpers.paginate.Page. Retrieving all the documents would
take 2 seconds on my old machine. Although inefficient, it was
acceptable for the users, and easy to program.
But with Solr, a query retrieving all documents takes much longer
(that's why Solr defaults to "partial" queries, I guess), so pagination
need to be integrated upstream. It can take place in Solr itself :
> si = SolrInterface( url = 'http://localhost:8080/solr',
> http_connection = httplib2.Http(cache='/tmp/solr_cache')
> )
> query = si.query(**search_args).paginate(start=10, rows=30)
> results = query.execute()
This works fine, but then you need to setup "fake" results if you want
to use the paginate module, something like :
> page = Page([], item_count=results.result.numFound)
Luckily, the sunbunrt query object provides a __getitem__ method, so I
can write :
> page = Page(query)
This is a very welcome change as compared with webhelpers.paginate,
where only SQLAlchemy query were allowed :-)
==
IMHO, the pager needs some more polish:
1/ I had to handle URL generation myself, here is how I did is (cleaner
solutions welcome :-))
> qsd = urlparse.parse_qs(request.query_string)
> qsd.update(page='$page')
> page_url = request.path_url + '?' +
> urllib.urlencode(qsd,True).replace('%24page', '$page')
2/ Unicode characters such as "«" and "»" (angled double quotes) were
not accepted in symbol_previous and symbol_next, so I kept the defaults
("<" and ">").
3/ The paginate module has lost webhelpers.paginate's ability to handle
partial page loads with AJAX (via the "onclick" argument).
Hope this helps,
Laurent.
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.