Class n.g.SessionWrapper:

Part of nevow.guard View Source View In Hierarchy

Implements interfaces: nevow.inevow.IResource

SessionWrapper




The following class attributes can be modified on an instance
of the class.

@ivar secureCookies: Whether to use secure (TLS only) cookies or not.
  True (default): make cookies secure when session is initiated
  in a secure (TLS) connection.

  False: cookies do not get the secure attribute.

@ivar: persistentCookies: Whether to use persistent (saved to disk) cookies or not.
  True: make cookies persistent, so they are valid for the
    length of the sessionLifetime even if the browser window
    is closed.

  False (default): cookies do not get saved to disk, and thus last
    only as long as the session does.  If the browser is
    closed before the session timeout, both the session
    and the cookie go away.
Line # Kind Name Docs
259 Method __init__ Undocumented
275 Method renderHTTP Render a request
288 Method locateChild Locate another object which can be adapted to IResource
359 Method createSession Create a new session for this request, and redirect back to the path
387 Method checkLogin Associate the given request with the given session and:
481 Method explicitLogout Hook to be overridden if you care about user-requested logout.
505 Method getCredentials Undocumented
510 Method login
  • Calls login() on our portal.
537 Method incorrectLoginError Used as an errback upon failed login, returns a 2-tuple of a failure URL
559 Method authRequiredError Undocumented
def __init__(self, portal, cookieKey=None, mindFactory=None, credInterface=None, useCookies=None): (source)
Undocumented
def renderHTTP(self, ctx): (source)
Render a request
def locateChild(self, ctx, segments): (source)
Locate another object which can be adapted to IResource Return a tuple of resource, path segments
def createSession(self, ctx, segments): (source)
Create a new session for this request, and redirect back to the path given by segments.
def checkLogin(self, ctx, session, segments, sessionURL=None, httpAuthCredentials=None): (source)
Associate the given request with the given session and:
  • log the user in to our portal, if they are accessing a login URL
  • log the user out from our portal (calling their logout callback), if they are logged in and accessing a logout URL
Returns
  • if the user is already logged in: a 2-tuple of requestObject, segments (i.e. the segments parameter)
  • if the user is not logged in and not logging in, call login() to initialize an anonymous session, and return a 2-tuple of (rootResource, segments-parameter) from that anonymous session. This counts as logging in for the purpose of future calls to checkLogin.
  • if the user is accessing a login URL: a 2-tuple of the logged in resource object root and the remainder of the segments (i.e. the URL minus __login__) to be passed to that resource.
def explicitLogout(self, session): (source)
Hook to be overridden if you care about user-requested logout.

Note: there is no return value from this method; it is purely a way to
provide customized behavior that distinguishes between session-expiry
logout, which is what 99% of code cares about, and explicit user
logout, which you may need to be notified of if (for example) your
application sets other HTTP cookies which refer to server-side state,
and you want to expire that state in a manual logout but not with an
automated logout.  (c.f. Quotient's persistent sessions.)

If you want the user to see a customized logout page, just generate a
logout link that looks like

    http://your-site.example.com/__logout__/my/custom/logout/stuff

and the user will see

    http://your-site.example.com/my/custom/logout/stuff

as their first URL after becoming anonymous again.
def getCredentials(self, request): (source)
Undocumented
def login(self, request, session, credentials, segments): (source)
  • Calls login() on our portal.
  • creates a mind from my mindFactory, with the request and credentials
  • Associates the mind with the given session.
  • Associates the resource returned from my portal's login() with my portal in the given session.
Returnsa Deferred which fires a 2-tuple of the resource returned from my portal's login() and the passed list of segments upon successful login.
def incorrectLoginError(self, error, ctx, segments, loginFailure): (source)
Used as an errback upon failed login, returns a 2-tuple of a failure URL with the query argument 'login-failure' set to the parameter loginFailure, and an empty list of segments, to redirect to that URL. The basis for this error URL, i.e. the part before the query string, is taken either from the 'referer' header from the given request if one exists, or a computed URL that points at the same page that the user is currently looking at to attempt login. Any existing query string will be stripped.
def authRequiredError(self, error, session): (source)
Undocumented
API Documentation for Nevow, generated by pydoctor.