Hello,

Im currently working with an application where I want to send a clean command into the url without encoded url value strings, in order to cleanly serve and parse the delivered values from url_for to a javascript handling.

The need also came up as I didnt found a way to cleanly redirect to a url generated by url_for - without implementing addional checkups to serve data to the Jinja templating engine, but had to respond to client interactions from within Javascript code.

Also the returned encoded url looks kindly strange for my taste and doesnt suit to "modern" web application design - possible users might be irritated by the url_encode(d) url strings.

Therefore I tried to implement a small patch to avoid the encoding of urls, if I know that the returned data is made saint inside my application when returned to the user.

I added a small change in werkzeug.routing in order to receive what I wanted to do, but I can guess that this is by far not the most elegant way to do, but it does work for me.

My custom url_for looks like this (when using it):
url_for('lookup_handle', doEncode=False, myCmd='someCommandValue')

The change is in werkzeug.routing from 729 to 744
        
try:
        # check if the value "doEncode" is present
        doEncode = query_vars['doEncode']   # doEncode = False
        
        if doEncode != False:   #check if the value is really set false
                raise
                
        del query_vars['doEncode']
        commands = ''
        for cmd in query_vars:
                commands += query_vars[cmd]

        url += '?'+commands

except:
        # original werkzeug code part
        url += '?' + url_encode(query_vars, self.map.charset,
                                                        
sort=self.map.sort_parameters,
                                                        key=self.map.sort_key)

        # original werkzeug code end



Perhaps this idea might be carried further and implemented further version of Flask/Werkzeug.


Regards,
Jan Riechers

--
You received this message because you are subscribed to the Google Groups 
"pocoo-libs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pocoo-libs?hl=en.

Reply via email to