what is wrong with this python code?
if query.find('&page=') != -1: query = query[:query.find('&page=')] (aim to strip out all after &page= in a query string) it don't works if query (pass as parameter, it is HTTP_QUERY) has %3A caracters *ex: when you have field:string in a web form* why find gives error? :( ________________________________________________ Message sent using ALFANET Caorle WEBMAIL 1.0
On Fri, 2003-11-07 at 11:44, Yurj wrote:
if query.find('&page=') != -1: query = query[:query.find('&page=')]
At the very least, you have an indentation problem.
(aim to strip out all after &page= in a query string)
Is that *really* what you want to do? I don't think *I* would want to rely on query strings being presented in a particular order. I'm guessing what you really want is to parse out the value of several variables. If so, why not just let Zope do the heavy lifting? ----- my_var = request.get('some_var') if my_var: do_stuff() ----- HTH, Dylan
Yurj wrote at 2003-11-7 18:44 -0100:
if query.find('&page=') != -1: query = query[:query.find('&page=')]
(aim to strip out all after &page= in a query string)
it don't works if query (pass as parameter, it is HTTP_QUERY) has %3A caracters *ex: when you have field:string in a web form*
why find gives error? :(
The "ZTUtils" package (in "lib/python") gives you much better ways to construct queries. Please look at "url_query", "make_query", "make_hidden_input" in its "Zope.py" module. -- Dieter
participants (3)
-
Dieter Maurer -
Dylan Reinhardt -
Yurj