[Zope] newbie question

Alexander Staubo alex@mop.no
Sun, 4 Jul 1999 00:02:00 +0200


>-----Original Message-----
>From: zope-admin@zope.org [mailto:zope-admin@zope.org]On
>Behalf Of Jenny
>Campbell
>Sent: 3. juli 1999 23:49
>To: Tony McDonald
>Cc: zope
>Subject: Re: [Zope] newbie question
>
>
>Thanks for your help Tony/Bill
>
>I'm making progress with this but have a few more questions:
>
>1.      I've just worked out I need to pass two parameters to
>the second query
>(branch and customer no). If I hardcode the branch no into the
>SQL method and
>pass only the customer number  it works, but how do I pass
>both variables? I've
>tried using a + and & between the two variables as below but no joy.
>
>        <tr>
>          <td><a href="linktest02?Branch=<!--#var
>cu_branch-->&linktest02?Customer=<!--#var cu_customer-->"</a>
>            <!--#var cu_branch null=""--> / <!--#var
>cu_customer null=""--></td>
>
>          <td><!--#var cu_name null=""--></td>
>          <td><!--#var cu_street_add3 null=""--></td>
>        </tr>

I have not followed your thread, but it looks like you're not too
familiar with how URLs are composed. The correct URL you're trying to
put together seems to be::

	linktest02?Branch=(value)&Customer=(value)

? is the start character for the query string; & separates arguments; =
separates the argument name and value.

In other words, your DTML should say::

>          <td><a href="linktest02?Branch=<!--#var
>cu_branch-->&Customer=<!--#var cu_customer-->"</a>

In addition to this there's URL encoding, which is significant when your
argument names or values may contain illegal characters (illegal in an
URL, that is). URL encoding converts illegal characters into the format
%XX where XX is the hexadecimal representation of the value; in
additional to this it turns spaces into "+". So if you have an argument
"foo" which has the value "a=b" then URL encoding translates this into::

	some_document?foo=a%3Db

(since the character "="'s hex value is 3D.) Happily, Zope supports URL
encoding, so modified, your DTML becomes::

>          <td><a href="linktest02?Branch=<!--#var
>cu_branch url_quote-->&Customer=<!--#var cu_customer url_quote-->"</a>

"url_quote" is the magic word that makes Zope encode the variable
correctly.

Interestingly, Internet Explorer is much more lenient about handling
illegal URL characters than Netscape; you might discover that URLs that
worked perfectly in IE "suddenly" don't work at all in Netscape, so
watch out. As a rule of thumb, _Always_ use url_quote when passing
variables inside <a href="..."> HTML tags (but only after the "?"
character, to wit).

[snip]

>--
>Jenny Campbell
>User Support - Applications
>Eastern Equities Limited
>Ph: 06-876 7943  Fax: 06-876 8811
>
>---------------------------------
>
>
>
>_______________________________________________
>Zope maillist  -  Zope@zope.org
>http://www.zope.org/mailman/listinfo/zope
>
>(For developer-specific issues, use the companion list,
>zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev )
>