# HG changeset patch # User paulb # Date 1190932825 0 # Node ID 933a8a32a07c78e5b6bd496aa5c59d6530c7e8a5 # Parent 40c05879f66bff2fc1cf6b5448bbed92f48f139b [project @ 2007-09-27 22:40:25 by paulb] Updated the simple with login example. Support both WSGI over CGI and wsgiref. diff -r 40c05879f66b -r 933a8a32a07c examples/WSGI/SimpleWithLoginApp.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/WSGI/SimpleWithLoginApp.py Thu Sep 27 22:40:25 2007 +0000 @@ -0,0 +1,41 @@ +#!/usr/bin/env python + +# Uncomment and adjust the paths below if WebStack is not installed somewhere +# on the PYTHONPATH. + +#import sys +#sys.path.append("/home/paulb/Software/Python/WebStack") +#sys.path.append("/home/paulb/Software/Python/WebStack/examples/Common") + +from WebStack.Adapters.WSGI import deploy +from WebStack.Resources.LoginRedirect import LoginRedirectResource, LoginRedirectAuthenticator +from WebStack.Resources.Login import LoginResource, LoginAuthenticator +from WebStack.Resources.ResourceMap import MapResource +from Simple import SimpleResource + +deploy( + MapResource({ + "simple" : + LoginRedirectResource( + login_url="http://localhost:8080/login", + app_url="http://localhost:8080", + resource=SimpleResource(), + authenticator=LoginRedirectAuthenticator(secret_key="horses"), + anonymous_parameter_name="anonymous", + logout_parameter_name="logout" + ), + "login" : + LoginResource( + LoginAuthenticator( + secret_key="horses", + credentials=( + ("badger", "abc"), + ("vole", "xyz"), + ) + ) + ) + }), + handle_errors=1 +) + +# vim: tabstop=4 expandtab shiftwidth=4 diff -r 40c05879f66b -r 933a8a32a07c examples/WSGI/SimpleWithLoginHandler.py --- a/examples/WSGI/SimpleWithLoginHandler.py Thu Sep 27 22:39:38 2007 +0000 +++ b/examples/WSGI/SimpleWithLoginHandler.py Thu Sep 27 22:40:25 2007 +0000 @@ -7,19 +7,35 @@ #sys.path.append("/home/paulb/Software/Python/WebStack") #sys.path.append("/home/paulb/Software/Python/WebStack/examples/Common") -from WebStack.Adapters.WSGI import deploy +from WebStack.Adapters.WSGI import deploy_as_cgi from WebStack.Resources.LoginRedirect import LoginRedirectResource, LoginRedirectAuthenticator +from WebStack.Resources.Login import LoginResource, LoginAuthenticator +from WebStack.Resources.ResourceMap import MapResource from Simple import SimpleResource -deploy( - LoginRedirectResource( - login_url="http://localhost/wsgi/login", - app_url="http://localhost", - resource=SimpleResource(), - authenticator=LoginRedirectAuthenticator(secret_key="horses"), - anonymous_parameter_name="anonymous", - logout_parameter_name="logout" - ) +deploy_as_cgi( + MapResource({ + "simple" : + LoginRedirectResource( + login_url="http://localhost/wsgi/login", + app_url="http://localhost", + resource=SimpleResource(), + authenticator=LoginRedirectAuthenticator(secret_key="horses"), + anonymous_parameter_name="anonymous", + logout_parameter_name="logout" + ), + "login" : + LoginResource( + LoginAuthenticator( + secret_key="horses", + credentials=( + ("badger", "abc"), + ("vole", "xyz"), + ) + ) + ) + }), + handle_errors=1 ) # vim: tabstop=4 expandtab shiftwidth=4