Re: WebHelpers developments (paginate 0.4.0 released)

2013-02-12 Thread Laurent DAVERIO
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.




Re: pyramid module's i18n (config.include included)

2013-02-12 Thread Chris Rossi
On Tue, Feb 12, 2013 at 9:22 AM, Grzegorz Śliwiński wrote:

> Hi,
>
> I'm working on some i18n app in pyramid, and also extracted some
> functionality into common modules which provide functionality and actions.
> And I have several questions about i18n process in pyramid:
> Is it possible to provide translations for messages delivered in this
> project?
> Can I >>overwrite<< this translations in pyramid app somehow?
>
Where's the extract point for messages from such plugin?
>

To the extent that I understand what you're asking, I think it's pretty
well covered in the documentation:

http://docs.pylonsproject.org/projects/pyramid/en/1.4-branch/narr/i18n.html

Chris

-- 
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.




pyramid module's i18n (config.include included)

2013-02-12 Thread Grzegorz Śliwiński
Hi,

I'm working on some i18n app in pyramid, and also extracted some 
functionality into common modules which provide functionality and actions. 
And I have several questions about i18n process in pyramid:
Is it possible to provide translations for messages delivered in this 
project? 
Can I >>overwrite<< this translations in pyramid app somehow?
Where's the extract point for messages from such plugin?

-- 
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.