[Zope] Re: using a variable plus attribute inside a DTML-CALL
4 Oct 2001 14:06:56 GMT
Mitchell L Model <email@example.com> wrote:
> > I am constructing a URL for a redirection based on a variable 'arg'
> >in the REQUEST.
> > I can use that variable in a DTML-CALL, as follows (helped by
> >discussions I found at
> > NIP from a while ago in this list, e.g.
> > <dtml-call
> > expr="RESPONSE.redirect('http://www.zope.org/SiteIndex/search?text_content='
> > + arg)">
> > However, I want to url_quote_plus the arg. The usual variable
> >attribute syntax (either <dtml-var
> > arg.url_quote_plus> or &dtml.url_quote_plus.arg;) isn't available
> >inside the Python expression in the
> > dtml-call. Without creating an external method to do the quoting,
> >how can I get the quoted version of the
> > variable inside the Python expression? I've tried lots of
> >different ideas, but none worked.
url_quote_plus cannot be accessed from Python Script.
- allow urllib to be imported from python script, see mailing-list
archives about how to allow a module to be imported
- or write an external method that does:
def quote_plus(self, s):
- or do it with a hack:
- make a DTML Method called dtml_quote_plus with:
<dtml-var s url_quote_plus>
- and call it from python in DTML using
All untested of course.
Florent Guillaume, Nuxeo SARL (Paris, France)
+33 1 40 33 79 87 http://nuxeo.com mailto:firstname.lastname@example.org