XSLTools

XSLForms/Resources/OpenIDRedirect.py

687:ae7bdbf61e32
2009-06-22 Paul Boddie Added some error handling to the questionnaire application.
     1 #!/usr/bin/env python     2      3 """     4 OpenID redirection resources for XSLForms applications. These resources use     5 "root" attributes on transaction objects, and therefore should be defined within     6 the appropriate resources in site maps.     7      8 Copyright (C) 2006, 2007, 2008 Paul Boddie <paul@boddie.org.uk>     9     10 This program is free software; you can redistribute it and/or modify it under    11 the terms of the GNU Lesser General Public License as published by the Free    12 Software Foundation; either version 3 of the License, or (at your option) any    13 later version.    14     15 This program is distributed in the hope that it will be useful, but WITHOUT    16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    17 FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more    18 details.    19     20 You should have received a copy of the GNU Lesser General Public License along    21 with this program.  If not, see <http://www.gnu.org/licenses/>.    22 """    23     24 import WebStack.Resources.OpenIDRedirect # OpenIDRedirectResource    25     26 OpenIDRedirectAuthenticator = WebStack.Resources.OpenIDRedirect.OpenIDRedirectAuthenticator    27     28 class OpenIDRedirectResource(WebStack.Resources.OpenIDRedirect.OpenIDRedirectResource):    29     30     "A redirect resource which uses dynamic knowledge about the URL space."    31     32     def __init__(self, host, path_to_login, *args, **kw):    33     34         """    35         Initialise the resource with the 'host', 'path_to_login' (the path from    36         the root of the application to the login screen), and other    37         LoginRedirectResource details.    38     39         To get the root of the application, this resource needs an attribute on    40         the transaction called "root".    41     42         Examples of 'path_to_login' with "root" attribute and result:    43     44         "login", "/" -> "/login"    45         "login", "/app/" -> "/app/login"    46         "app/login", "/" -> "/app/login"    47         """    48     49         self.host = host    50         self.path_to_login = path_to_login    51         WebStack.Resources.OpenIDRedirect.OpenIDRedirectResource.__init__(self, *args, **kw)    52     53     def get_app_url(self, trans):    54         return self.host    55     56     def get_login_url(self, trans):    57         return self.host + trans.get_attributes()["root"] + self.path_to_login    58     59 # vim: tabstop=4 expandtab shiftwidth=4