On Monday, October 11, 2010 15:25:52 Remi Jolin wrote:
> Hello,
>
> I've just found a QR-Code reader that adds a variable to the encoded URL
> before passing it to the navigator and this variable is
> "mobiletag-title=http%3A%2F%2Fwww...etc....".
> The problem is that TG tries to decode that variable through
> formencode/variabledecode/variable_decode which is not pleased by the "-"
>
> Traceback (most recent call last):
> File
> "c:\Python25\lib\site-packages\cherrypy-2.3.0-py2.5.egg\cherrypy\_cphttpto
> ols.py", line 119, in _run applyFilters('before_main')
> File
> "c:\Python25\lib\site-packages\cherrypy-2.3.0-py2.5.egg\cherrypy\filters\_
> _init__.py", line 151, in applyFilters method()
> File
> "c:\Python25\lib\site-packages\turbogears-1.1-py2.5.egg\turbogears\filters
> \base.py", line 69, in before_main request.params =
> NestedVariables.to_python(request.params or {}) File
> "c:\python25\lib\site-packages\formencode-1.2.3dev-py2.5.egg\formencode\ap
> i.py", line 413, in to_python value = tp(value, state)
> File
> "c:\python25\lib\site-packages\formencode-1.2.3dev-py2.5.egg\formencode\va
> riabledecode.py", line 141, in _to_python return variable_decode(value)
> File
> "c:\python25\lib\site-packages\formencode-1.2.3dev-py2.5.egg\formencode\va
> riabledecode.py", line 49, in variable_decode new_keys.append(int(index))
> ValueError: invalid literal for int() with base 10: 'title'
>
> What can I do to solve this issue ? Any suggestion ?
> (changing the QR-Code reader is not an option as the TG application is
> supposed to be used by anybody)
I think your best option is to install a filter that alters the request so that
the attribute name "mobiletag-title" gets re-mapped to e.g. mobiletag_title.
The reason for the problem is the formencode convention to serialize compound
parameter lists. For example, if you have a form that contains several
addresses, it will be rendered to input-tag names like this:
addresses-0.street
addresses-0.zip
addresses-1.street
addresses-1.zip
So it' a crucial piece of the request workflow to decode these, and using a
filter is the eaisiest option.
Diez
--
You received this message because you are subscribed to the Google Groups
"TurboGears" 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/turbogears?hl=en.