application processor returning page with "function <lambda>..."

26 views
Skip to first unread message

Bill Seitz

unread,
Sep 24, 2012, 8:02:54 AM9/24/12
to we...@googlegroups.com
I'm trying to stick an application processor in my app to check whether the user is logged in. The code is:

def check_authorized(handle):
    path = web.ctx.path
    if path in ('/login', '/register'):
    return handle
    if not session.has_key('user_id'):
        web.debug('check_authorized: no session user_id')
        raise web.seeother('/static/splash.html')
    return handle
app.add_processor(check_authorized)

When I hit the "normal" pages I get bounced to the splash page nicely.

But when I hit /login or /register I get a page whose entire contents are:
<function <lambda> at 0x101bd6578>

What stupid mistake am I making?

Jason Macgowan

unread,
Sep 27, 2012, 3:01:40 PM9/27/12
to we...@googlegroups.com
You're returning an instance of a function instead of the value of the function.  Change "return handle" to return handle()

--
You received this message because you are subscribed to the Google Groups "web.py" group.
To view this discussion on the web visit https://groups.google.com/d/msg/webpy/-/K9DkQ-NkcQ4J.
To post to this group, send email to we...@googlegroups.com.
To unsubscribe from this group, send email to webpy+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webpy?hl=en.

Bill Seitz

unread,
Sep 28, 2012, 12:48:30 PM9/28/12
to we...@googlegroups.com
Derp! That worked, thanks!
Reply all
Reply to author
Forward
0 new messages