Files
@ a83a1799480c
Branch filter:
Location: kallithea/pylons_app/controllers/login.py - annotation
a83a1799480c
1.4 KiB
text/x-python
Reimplemented way of caching repos list, hg model now get's repos objects right from cached dict, this way we skipp creating instances of MercurialRepository and gain performance. Some import cleanup
556473ba0399 556473ba0399 556473ba0399 556473ba0399 556473ba0399 556473ba0399 556473ba0399 556473ba0399 556473ba0399 556473ba0399 556473ba0399 556473ba0399 556473ba0399 3fd2af1ba5ea 3fd2af1ba5ea 3fd2af1ba5ea 556473ba0399 7109d15c6813 7109d15c6813 556473ba0399 556473ba0399 556473ba0399 556473ba0399 556473ba0399 556473ba0399 556473ba0399 556473ba0399 556473ba0399 556473ba0399 556473ba0399 556473ba0399 556473ba0399 556473ba0399 556473ba0399 556473ba0399 556473ba0399 556473ba0399 556473ba0399 556473ba0399 556473ba0399 3fd2af1ba5ea 556473ba0399 | import logging
from formencode import htmlfill
from pylons import request, response, session, tmpl_context as c, url
from pylons.controllers.util import abort, redirect
from pylons_app.lib.base import BaseController, render
import formencode
from pylons_app.model.forms import LoginForm
from pylons_app.lib.auth import AuthUser
log = logging.getLogger(__name__)
class LoginController(BaseController):
def __before__(self):
super(LoginController, self).__before__()
def index(self):
#redirect if already logged in
if c.hg_app_user.is_authenticated:
return redirect(url('hg_home'))
if request.POST:
#import Login Form validator class
login_form = LoginForm()
try:
c.form_result = login_form.to_python(dict(request.POST))
return redirect(url('hg_home'))
except formencode.Invalid as errors:
c.form_errors = errors.error_dict
return htmlfill.render(
render('/login.html'),
defaults=errors.value,
encoding="UTF-8")
return render('/login.html')
def logout(self):
session['hg_app_user'] = AuthUser()
session.save()
log.info('Logging out and setting user as Empty')
redirect(url('hg_home'))
|