1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/examples/Common/SimpleWithLogin/__init__.py Sat Nov 15 02:33:06 2008 +0100
1.3 @@ -0,0 +1,41 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +from WebStack.Generic import ContentType
1.7 +from WebStack.Resources.LoginRedirect import LoginRedirectResource, LoginRedirectAuthenticator
1.8 +from WebStack.Resources.Login import LoginResource, LoginAuthenticator
1.9 +from WebStack.Resources.ResourceMap import MapResource
1.10 +from Simple import SimpleResource
1.11 +
1.12 +def get_site_map(app_url, login_url, secret_key):
1.13 +
1.14 + """
1.15 + Resource a resource for the site having the given 'app_url' and 'login_url',
1.16 + using the given 'secret_key' for authentication tokens.
1.17 + """
1.18 +
1.19 + simple = LoginRedirectResource(
1.20 + login_url=login_url,
1.21 + app_url=app_url,
1.22 + resource=SimpleResource(),
1.23 + authenticator=LoginRedirectAuthenticator(secret_key=secret_key)
1.24 + )
1.25 +
1.26 + simple.anonymous_parameter_name = "anonymous"
1.27 + simple.logout_parameter_name = "logout"
1.28 +
1.29 + return MapResource({
1.30 + "simple" : simple,
1.31 + "login" :
1.32 + LoginResource(
1.33 + LoginAuthenticator(
1.34 + secret_key=secret_key,
1.35 + credentials=(
1.36 + ("badger", "abc"),
1.37 + ("vole", "xyz"),
1.38 + )
1.39 + )
1.40 + ),
1.41 + "" : simple
1.42 + })
1.43 +
1.44 +# vim: tabstop=4 expandtab shiftwidth=4