Le 7 avr. 2011 à 17:01, Christian Ledermann a écrit :
> Hello,
>
> How can i encode the parameters:
>
> {'Creator': '', 'portal_type': ['ContactDb', 'FormFolder'], 'sort_on':
> '', 'SearchableText': '', 'created': [DateTime('1970/02/01')],
> 'review_state': ['pending', 'private', 'published', 'sent']}
>
> in a zope/plone conform manner i.e to:
>
> SearchableText=&portal_type%3Alist=ContactDb&portal_type%3Alist=FormFolder&created%3Alist%3Adate=1970%2F02%2F01&created_usage=range%3Amin&review_state%3Alist=pending&review_state%3Alist=private&review_state%3Alist=published&review_state%3Alist=sent&Creator=&sort_on=&b_size%3Aint=30&submit=Search
>
> the python urlib.urlencode returns:
>
> Creator=&portal_type=%5B%27ContactDb%27%2C+%27FormFolder%27%5D&sort_on=&SearchableText=&created=%5BDateTime%28%271970%2F02%2F01%27%29%5D&review_state=%5B%27pending%27%2C+%27private%27%2C+%27published%27%2C+%27sent%27%5D
>
> which will not be correctly interpreted into the request.form
ZTUtils.make_query and ZTUtils.url_query are your friends
$ bin/zopepy
>>> from ZTUtils import make_query
>>> from DateTime import DateTime
>>> dict_query = {'Creator': '', 'portal_type': ['ContactDb', 'FormFolder'],
>>> 'sort_on': '', 'SearchableText': '', 'created':
>>> [DateTime('1970/02/01')],'review_state': ['pending', 'private',
>>> 'published', 'sent']}
>>> make_query(**dict_query)
'created:date:list=1970/02/01&Creator=&portal_type:list=ContactDb&portal_type:list=FormFolder&sort_on=&review_state:list=pending&review_state:list=private&review_state:list=published&review_state:list=sent&SearchableText='
HTH...
--
Gilles Lenfant
>
>
>
> --
> Best Regards,
>
> Christian Ledermann
>
> Nairobi - Kenya
> Mobile : +254 729495789
>
> <*)))>{
>
> If you save the living environment, the biodiversity that we have left,
> you will also automatically save the physical environment, too. But If
> you only save the physical environment, you will ultimately lose both.
>
> 1) Don’t drive species to extinction
>
> 2) Don’t destroy a habitat that species rely on.
>
> 3) Don’t change the climate in ways that will result in the above.
>
> }<(((*>
> _______________________________________________
> Product-Developers mailing list
> [email protected]
> https://lists.plone.org/mailman/listinfo/product-developers
_______________________________________________
Product-Developers mailing list
[email protected]
https://lists.plone.org/mailman/listinfo/product-developers