1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/examples/Common/SimpleWithOpenID/__init__.py Sat Nov 24 01:38:48 2007 +0000
1.3 @@ -0,0 +1,52 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +from WebStack.Generic import ContentType
1.7 +from WebStack.Resources.OpenIDRedirect import OpenIDRedirectResource, OpenIDRedirectAuthenticator
1.8 +from WebStack.Resources.OpenIDInitiation import OpenIDInitiationResource
1.9 +from WebStack.Resources.ResourceMap import MapResource
1.10 +from WebStack.Resources.Static import StringResource
1.11 +from Simple import SimpleResource
1.12 +
1.13 +def get_site_map(app_url, initiation_url, secret_key):
1.14 +
1.15 + """
1.16 + Resource a resource for the site having the given 'app_url', using the given
1.17 + 'initiation_url' for the OpenID initiation page, and the specified
1.18 + 'secret_key' for authentication tokens.
1.19 + """
1.20 +
1.21 + return MapResource({
1.22 + "simple" :
1.23 + OpenIDRedirectResource(
1.24 + login_url=initiation_url,
1.25 + app_url=app_url,
1.26 + resource=SimpleResource(),
1.27 + authenticator=OpenIDRedirectAuthenticator(
1.28 + secret_key=secret_key,
1.29 + app_url=app_url
1.30 + ),
1.31 + anonymous_parameter_name="anonymous",
1.32 + logout_parameter_name="logout"
1.33 + ),
1.34 +
1.35 + # The "login" is really OpenID initiation.
1.36 +
1.37 + "login" : OpenIDInitiationResource(),
1.38 +
1.39 + # A root page.
1.40 +
1.41 + "" :
1.42 + StringResource("""
1.43 + <html>
1.44 + <head>
1.45 + <title>Simple Application with OpenID Login</title>
1.46 + </head>
1.47 + <body>
1.48 + <p>Access the application <a href="simple">here</a>.</p>
1.49 + </body>
1.50 + </html>
1.51 + """, ContentType("text/html"))
1.52 +
1.53 + })
1.54 +
1.55 +# vim: tabstop=4 expandtab shiftwidth=4