If you just want to specify a URL for redirect, you can do so without the
lambda:
auth.settings.on_failed_authentication = URL('painel', 'index')
However, if you do define a lambda (or any callable), it should accept an
argument.
Anthony
On Wednesday, July 9, 2014 9:31:17 PM UTC-4, Júlia Rizza wrote:
>
> I've completely forgot about the on_failed_authentication, sorry.
>
> *models/db.py*
> auth.settings.on_failed_authentication = lambda: redirect(URL('painel',
> 'index'))
>
> (web2py version 2.8.2-stable)
>
>
> Em quarta-feira, 9 de julho de 2014 21h31min19s UTC-3, Anthony escreveu:
>>
>> Did you change auth.settings.on_failed_authentication from its default
>> value?
>>
>> On Wednesday, July 9, 2014 8:11:25 PM UTC-4, Júlia Rizza wrote:
>>>
>>> Hello,
>>>
>>> I have an app runing in production on Apache and sometimes when
>>> navigating over it I receive a ticket with a lambda error. It happens
>>> ramdomly in a way that I wasn't able to predict what was causing it:
>>> already ocurred in a function called dashboard, in another called invite
>>> and some others. But the fact is that I do not call lambda in none of them.
>>> I only use lambda two times:
>>>
>>> *models/validators.py*
>>> db.board.slug.compute = lambda row: IS_SLUG()(row.title)[0]
>>>
>>> *controllers/painel.py | function: board()*
>>> try:
>>> int(request.args(1))
>>> user = db(db.auth_user.username == request.args(0)).select().first()
>>> board = db((db.board.created_by == user.id)&(db.board.id ==
>>> request.args(1))).select().first()
>>> except ValueError:
>>> user = db(db.auth_user.username == request.args(0)).select().first()
>>> board = db((db.board.created_by == user.id)&(db.board.slug ==
>>> request.args(1))).select().first()
>>> except TypeError:
>>> raise HTTP(404, T('No board specified!'))
>>>
>>> text_type = db(db.text_type.board == board.id).select()
>>> url_type = db(db.url_type.board == board.id).select()
>>> image_type = db(db.image_type.board == board.id).select()
>>> video_type = db(db.video_type.board == board.id).select()
>>>
>>> merged_records = itertools.chain(text_type, url_type, image_type,
>>> video_type)
>>> contents = sorted(merged_records, key=lambda record:
>>> record['topic_position'])
>>>
>>> The ticket *traceback* is:
>>> <type 'exceptions.TypeError'> <lambda>() takes no arguments (1 given)
>>>
>>> 1.
>>> 2.
>>> 3.
>>> 4.
>>> 5.
>>> 6.
>>> 7.
>>> 8.
>>> 9.
>>> 10.
>>> 11.
>>> 12.
>>>
>>> Traceback (most recent call last):
>>> File "/home/www-data/web2py/gluon/restricted.py", line 217, in restricted
>>> exec ccode in environment
>>> File "/home/www-data/web2py/applications/cachola/controllers/painel.py"
>>> <https://cacho.la/admin/default/edit/cachola/controllers/painel.py>, line
>>> 519, in <module>
>>> File "/home/www-data/web2py/gluon/globals.py", line 372, in <lambda>
>>> self._caller = lambda f: f()
>>> File "/home/www-data/web2py/gluon/tools.py", line 3229, in f
>>> '?_next=' + urllib.quote(next))
>>> File "/home/www-data/web2py/gluon/tools.py", line 91, in call_or_redirect
>>> redirect(f(*args))
>>> TypeError: <lambda>() takes no arguments (1 given)
>>>
>>>
>>> Can somebody help me to understand where is the problem?
>>>
>>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.