import oilarchive
This commit is contained in:
commit
2bb49ff965
37 changed files with 1027 additions and 0 deletions
46
oilarchive/controllers.py
Normal file
46
oilarchive/controllers.py
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
from turbogears import controllers, expose
|
||||
# from model import *
|
||||
from turbogears import identity, redirect
|
||||
from cherrypy import request, response
|
||||
# from oilarchive import json
|
||||
# import logging
|
||||
# log = logging.getLogger("oilarchive.controllers")
|
||||
|
||||
class Root(controllers.RootController):
|
||||
@expose(template="oilarchive.templates.welcome")
|
||||
# @identity.require(identity.in_group("admin"))
|
||||
def index(self):
|
||||
import time
|
||||
# log.debug("Happy TurboGears Controller Responding For Duty")
|
||||
return dict(now=time.ctime())
|
||||
|
||||
@expose(template="oilarchive.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= 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= request.headers.get("Referer", "/")
|
||||
|
||||
response.status=403
|
||||
return dict(message=msg, previous_url=previous_url, logging_in=True,
|
||||
original_parameters=request.params,
|
||||
forward_url=forward_url)
|
||||
|
||||
@expose()
|
||||
def logout(self):
|
||||
identity.current.logout()
|
||||
raise redirect("/")
|
||||
Loading…
Add table
Add a link
Reference in a new issue