WebStack

Annotated examples/Twisted/SimpleWithLoginApp.py

154:f2878dc56e5d
2004-05-30 paulb [project @ 2004-05-30 17:21:41 by paulb] Moved LoginRedirect from the examples to WebStack.Resources.
paulb@139 1
#!/usr/bin/env python
paulb@139 2
paulb@139 3
from WebStack.Adapters import Twisted
paulb@154 4
from WebStack.Resources.LoginRedirect import LoginRedirectResource, LoginRedirectAuthenticator
paulb@139 5
from Simple import SimpleResource
paulb@139 6
import twisted.web.server
paulb@139 7
import twisted.internet.reactor
paulb@139 8
paulb@139 9
# Special magic incantation.
paulb@139 10
paulb@139 11
resource = LoginRedirectResource(
paulb@139 12
    login_url="http://localhost:8081",
paulb@139 13
    app_url="http://localhost:8080",
paulb@139 14
    resource=SimpleResource(),
paulb@139 15
    authenticator=LoginRedirectAuthenticator(secret_key="horses"),
paulb@153 16
    anonymous_parameter_name="anonymous",
paulb@153 17
    logout_parameter_name="logout"
paulb@139 18
)
paulb@139 19
paulb@139 20
top_level = Twisted.Dispatcher(resource)
paulb@139 21
site = twisted.web.server.Site(top_level)
paulb@139 22
twisted.internet.reactor.listenTCP(8080, site)
paulb@139 23
twisted.internet.reactor.run()
paulb@139 24
paulb@139 25
# vim: tabstop=4 expandtab shiftwidth=4