Strange, I used similar code it worked for me:

def require_auth(f):
    @wraps(f)
    def wrapper(*args, **kwargs):
        if 'user_id' not in session:
            flash('you must be logged in')
            return redirect(url_for('login'))
        return f(*args, **kwargs)
    return wrapper

On Thu, Oct 20, 2011 at 5:59 PM, Voltron <[email protected]> wrote:

> I am setting the session in my root resource as in:
>
> @auth.login_required
> def index():
>    session['hurl'] = "tomohawk"
>    session['test'] = "dfdfd"
>
> The error is:
>
> File "/media/programming/applications/libono/env/lib/python2.6/site-
> packages/flask/app.py", line 1518, in __call__
> File "/testapp/env/lib/python2.6/site-packages/flask/app.py", line
> 1518, in __call__
> return self.wsgi_app(environ, start_response)
> File "/testapp/env/lib/python2.6/site-packages/flask/app.py", line
> 1506, in wsgi_app
> response = self.make_response(self.handle_exception(e))
> File "/testapp/env/lib/python2.6/site-packages/flask/app.py", line
> 1504, in wsgi_app
> response = self.full_dispatch_request()
> File "/testapp/env/lib/python2.6/site-packages/flask/app.py", line
> 1264, in full_dispatch_request
> rv = self.handle_user_exception(e)
> File "/testapp/env/lib/python2.6/site-packages/flask/app.py", line
> 1262, in full_dispatch_request
> rv = self.dispatch_request()
> File "/testapp/env/lib/python2.6/site-packages/flask/app.py", line
> 1248, in dispatch_request
> return self.view_functions[rule.endpoint](**req.view_args)
> File "/testapp/plugins/auth_ext.py", line 18, in decorated_function
> print "session in auth: ", session['test']
> File "/testapp/env/lib/python2.6/site-packages/werkzeug/local.py",
> line 363, in <lambda>
> __getitem__ = lambda x, i: x._get_current_object()[i]
> KeyError: 'test'
>
> --
> 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.
>
>


-- 
Kudryavtsev Roman
mobile: +7 921 3291801

-- 
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