_vars = request.vars['vars'] or {}
subject = 'FEEDBACK: %s' % URL(c=_c,f=_f,args=_args,vars=_vars) ##### <----
vars doesn't like Storage
_vars is a string. You are trying to pass a string where it expects a dict()
On Wednesday, 16 May 2012 18:01:13 UTC-5, sebastian wrote:
>
> Hi All,
>
> I'd like to add a feedback form in layout.html so that the users can click
> on it on whatever page they are and send a message to the site admin. To be
> useful, the form must include the current page and vars so that the admin
> can click on a link and go to exactly the same place where the user wrote
> the feedback from.
>
> in layout I've added
>
> {{=LOAD('default',
> 'send_suggestion',
> vars={ 'c':request.controller,
> 'f':request.function,
> 'args':request.args,
> 'vars':request.vars},
> ajax_trap=True)}}
>
> in default.py
>
> def send_suggestion():
> form = SQLFORM.factory(
> Field('message', 'text', requires=IS_NOT_EMPTY())
> )
>
> if form.process().accepted:
> _c = request.vars['c']
> _f = request.vars['f']
> _args = request.vars['args'] or []
> _vars = request.vars['vars'] or {}
> subject = 'FEEDBACK: %s' % URL(c=_c,f=_f,args=_args) ##### <----
> it works
> subject = 'FEEDBACK: %s' %
> URL(c=_c,f=_f,args=_args,vars=_vars) ##### <---- vars doesn't like Storage
> response.flash = 'Thanks for your feedback'
> # will send email
>
>
> return form
>
>
> The problem is that URL *vars* doesn't like storage...
>
> Traceback (most recent call last):
>
>
> File "/home/sebas/dev/web2py/peerservices/gluon/restricted.py", line 205,
> in restricted
>
>
> exec ccode in environment
>
>
> File
> "/home/sebas/dev/web2py/peerservices/applications/peerservices/controllers/default.py"
>
> <http://localhost:8000/admin/default/edit/peerservices/controllers/default.py>,
> line 370, in <module>
>
>
> File "/home/sebas/dev/web2py/peerservices/gluon/globals.py", line 173, in
> <lambda>
>
>
> self._caller = lambda f: f()
>
>
> File
> "/home/sebas/dev/web2py/peerservices/applications/peerservices/controllers/default.py"
>
> <http://localhost:8000/admin/default/edit/peerservices/controllers/default.py>,
> line 301, in send_suggestion
>
>
> subject = 'FEEDBACK: %s' % URL(c=_c,f=_f,args=_args,vars=_vars)
>
>
> File "/home/sebas/dev/web2py/peerservices/gluon/html.py", line 290, in URL
>
>
> if vars.has_key('_signature'): vars.pop('_signature')
>
> AttributeError: 'str' object has no attribute 'has_key'
>
>
>
> Any better way than converting the Storage into dict ?
>
> thanks
> --
> Sebastian E. Ovide
>
>
>
>
>