Mercurial > genshi > mirror
view examples/turbogears/markuptest/controllers.py @ 224:90d62225f411 trunk
Implement support for namespace prefixes in XPath expressions.
author | cmlenz |
---|---|
date | Wed, 06 Sep 2006 14:39:50 +0000 |
parents | 64ff134868c4 |
children |
line wrap: on
line source
import logging import cherrypy import turbogears from turbogears import controllers, expose, validate, redirect, widgets from turbogears import identity from markuptest import json log = logging.getLogger("markuptest.controllers") class Root(controllers.RootController): @expose(template="markuptest.templates.welcome") def index(self): import time log.debug("Happy TurboGears Controller Responding For Duty") return dict(now=time.ctime(), widget=widgets.TextArea(name="widget_test", default="This is a test of using " "TurboGears widgets with " "Markup", rows=5, cols=40)) @expose(template="markuptest.templates.login") def login(self, forward_url=None, previous_url=None, *args, **kw): if not identity.current.anonymous \ and identity.was_login_attempted() \ and not identity.get_identity_errors(): raise redirect(forward_url) forward_url=None previous_url= cherrypy.request.path if identity.was_login_attempted(): msg=_("The credentials you supplied were not correct or " "did not grant access to this resource.") elif identity.get_identity_errors(): msg=_("You must provide your credentials before accessing " "this resource.") else: msg=_("Please log in.") forward_url= cherrypy.request.headers.get("Referer", "/") cherrypy.response.status=403 return dict(message=msg, previous_url=previous_url, logging_in=True, original_parameters=cherrypy.request.params, forward_url=forward_url) @expose() def logout(self): identity.current.logout() raise redirect("/")