comparison pylons_app/controllers/login.py @ 360:db187729c40c

new style error display for login
author Marcin Kuzminski <marcin@python-works.com>
date Sat, 24 Jul 2010 00:53:03 +0200
parents 3782a6d698af
children 98abf8953b87
comparison
equal deleted inserted replaced
359:339d1368c10d 360:db187729c40c
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # encoding: utf-8 2 # encoding: utf-8
3 # login controller for pylons 3 # login controller for pylons
4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com> 4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
5 5 #
6 # This program is free software; you can redistribute it and/or 6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License 7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; version 2 8 # as published by the Free Software Foundation; version 2
9 # of the License or (at your opinion) any later version of the license. 9 # of the License or (at your opinion) any later version of the license.
10 # 10 #
49 try: 49 try:
50 c.form_result = login_form.to_python(dict(request.POST)) 50 c.form_result = login_form.to_python(dict(request.POST))
51 return redirect(url('hg_home')) 51 return redirect(url('hg_home'))
52 52
53 except formencode.Invalid as errors: 53 except formencode.Invalid as errors:
54 c.form_errors = errors.error_dict
55 return htmlfill.render( 54 return htmlfill.render(
56 render('/login.html'), 55 render('/login.html'),
57 defaults=errors.value, 56 defaults=errors.value,
57 errors=errors.error_dict or {},
58 prefix_error=False,
58 encoding="UTF-8") 59 encoding="UTF-8")
59 60
60 return render('/login.html') 61 return render('/login.html')
61 62
62 def logout(self): 63 def logout(self):