[Twisted-web] url.URL flattener avoid url-encoding

Little mordaha at gmail.com
Wed Apr 27 06:24:00 MDT 2005

Page URI looks like this:


Template xml looks like this:

                <n:attr name="href"><n:slot name="href" /></n:attr>
                <n:slot name="base" />(<n:slot name="count" />)

Render code looks like this:

def render_href(self, ctx, data):
        u = url.URL.fromContext(ctx)
        u = u.replace("base", data[0])
        ctx.fillSlots("href", u)
        ctx.fillSlots("base", data[0])            
        ctx.fillSlots("count", data[1])          
        return ctx.tag


In this example, href of A-tag is not url-encoded. So, i have a link,
that looks like this:

<a href="http://localhost/index?text=abc def ert&base=base2">
(there are spaces in href)

To make valid link, i need to do urllib.quote by myself:

       from urllib import quote
       ctx.fillSlots("href", quote(str(u),':&/=?'))

Why URL flattener avoid urllib.quote? 

P.S. And may be using urllib.unquote_plus() is more correct in url.URL
than urllib.unquote()? (IE encoded form data spaces into '+' chars,
not into '%20')

P.P.S. nevow 0.4.1

More information about the Twisted-web mailing list