1.1 --- a/WebStack/Resources/Login.py Thu Jan 18 19:56:34 2007 +0000
1.2 +++ b/WebStack/Resources/Login.py Thu Jan 18 22:40:07 2007 +0000
1.3 @@ -41,6 +41,10 @@
1.4
1.5 The optional 'urlencoding' parameter allows a special encoding to be
1.6 used in producing the redirection path.
1.7 +
1.8 + To change the pages employed by this resource, either redefine the
1.9 + 'login_page' and 'success_page' attributes in instances of this class or
1.10 + a subclass, or override the 'show_login' and 'show_success' methods.
1.11 """
1.12
1.13 self.authenticator = authenticator
1.14 @@ -84,16 +88,32 @@
1.15 def show_login(self, trans, app, path, qs):
1.16
1.17 """
1.18 - Writes a login screen using the transaction 'trans', including details of the
1.19 - 'app', 'path' and 'qs' which the client was attempting to access.
1.20 + Writes a login screen using the transaction 'trans', including details
1.21 + of the 'app', 'path' and 'qs' which the client was attempting to access.
1.22 """
1.23
1.24 trans.set_content_type(WebStack.Generic.ContentType("text/html", self.encoding))
1.25 out = trans.get_response_stream()
1.26 - out.write("""
1.27 + out.write(self.login_page % (app, path, qs))
1.28 +
1.29 + def show_success(self, trans, app, path, qs):
1.30 +
1.31 + """
1.32 + Writes a success screen using the transaction 'trans', including details
1.33 + of the 'app', 'path' and 'qs' which the client was attempting to access.
1.34 + """
1.35 +
1.36 + # When authentication fails or is yet to take place, show the login
1.37 + # screen.
1.38 +
1.39 + trans.set_content_type(WebStack.Generic.ContentType("text/html", self.encoding))
1.40 + out = trans.get_response_stream()
1.41 + out.write(self.success_page % (app, trans.encode_path(path, self.urlencoding), qs))
1.42 +
1.43 + login_page = """
1.44 <html>
1.45 <head>
1.46 - <title>Login Example</title>
1.47 + <title>Login</title>
1.48 </head>
1.49 <body>
1.50 <h1>Login</h1>
1.51 @@ -107,16 +127,9 @@
1.52 </form>
1.53 </body>
1.54 </html>
1.55 -""" % (app, path, qs))
1.56 -
1.57 - def show_success(self, trans, app, path, qs):
1.58 +"""
1.59
1.60 - # When authentication fails or is yet to take place, show the login
1.61 - # screen.
1.62 -
1.63 - trans.set_content_type(WebStack.Generic.ContentType("text/html", self.encoding))
1.64 - out = trans.get_response_stream()
1.65 - out.write("""
1.66 + success_page = """
1.67 <html>
1.68 <head>
1.69 <title>Login Example</title>
1.70 @@ -126,7 +139,7 @@
1.71 <p>Please proceed <a href="%s%s%s">to the application</a>.</p>
1.72 </body>
1.73 </html>
1.74 -""" % (app, trans.encode_path(path, self.urlencoding), qs))
1.75 +"""
1.76
1.77 class LoginAuthenticator:
1.78