I am looking to create a module in my app that will have a
authentication class with methods to check if the user is logged-in
and such.

I wish to use session, request, redirect, etc. However, importing
gluon doesn't seem to expose those methods.

With the code below I keep getting an error that tells me "NameError:
global name 'redirect' is not defined"

Also, could someone give me a link to the python doc that explains the
use of @ such as

@cache...
def myfunc(): ...



my code:
**************************************************************
from gluon.storage import Storage
from gluon.html import *
from gluon.http import *
from gluon.validators import *
from gluon.sqlhtml import *

class auth:
    """
        @auth.requires_login('index')
        def userHomePage(): ...
    """

    def __init__(self, a_request, a_response, a_session, a_cache, a_T,
a_db):
       self.auth_request = a_request
       self.auth_response = a_response
       self.auth_session = a_session
       self.auth_cache = a_cache
       self.auth_T = a_T
       self.auth_db = a_db

    def requires_login(self, value):
        if(not self.auth_session.c__logged_in):
            redirect(URL(r=self.auth_request, c='root', f=value,
vars=self.auth_request.vars))
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to