mirror of
https://github.com/kakwa/ldapcherry
synced 2024-11-26 03:04:30 +01:00
adding support for display template parse error
This commit is contained in:
parent
e37b88dbda
commit
e1a27aa0a7
@ -30,6 +30,7 @@ from cherrypy.lib.httputil import parse_query_string
|
|||||||
# Mako template engines imports
|
# Mako template engines imports
|
||||||
from mako.template import Template
|
from mako.template import Template
|
||||||
from mako import lookup
|
from mako import lookup
|
||||||
|
from mako import exceptions
|
||||||
from sets import Set
|
from sets import Set
|
||||||
|
|
||||||
SESSION_KEY = '_cp_username'
|
SESSION_KEY = '_cp_username'
|
||||||
@ -1133,6 +1134,8 @@ class LdapCherry(object):
|
|||||||
standalone_groups = tmp['unusedgroups']
|
standalone_groups = tmp['unusedgroups']
|
||||||
roles_js = json.dumps(display_names, separators=(',', ':'))
|
roles_js = json.dumps(display_names, separators=(',', ':'))
|
||||||
key = self.attributes.get_key()
|
key = self.attributes.get_key()
|
||||||
|
|
||||||
|
try:
|
||||||
form = self.temp['form.tmpl'].render(
|
form = self.temp['form.tmpl'].render(
|
||||||
attributes=self.attributes.attributes,
|
attributes=self.attributes.attributes,
|
||||||
values=self._escape(user_attrs, 'attr_list'),
|
values=self._escape(user_attrs, 'attr_list'),
|
||||||
@ -1140,6 +1143,7 @@ class LdapCherry(object):
|
|||||||
keyattr=key,
|
keyattr=key,
|
||||||
autofill=False
|
autofill=False
|
||||||
)
|
)
|
||||||
|
|
||||||
roles = self.temp['roles.tmpl'].render(
|
roles = self.temp['roles.tmpl'].render(
|
||||||
roles=self.roles.flatten,
|
roles=self.roles.flatten,
|
||||||
graph=self.roles.graph,
|
graph=self.roles.graph,
|
||||||
@ -1147,7 +1151,8 @@ class LdapCherry(object):
|
|||||||
roles_js=roles_js,
|
roles_js=roles_js,
|
||||||
current_roles=user_roles,
|
current_roles=user_roles,
|
||||||
)
|
)
|
||||||
return self.temp['modify.tmpl'].render(
|
|
||||||
|
glued_template = self.temp['modify.tmpl'].render(
|
||||||
form=form,
|
form=form,
|
||||||
roles=roles,
|
roles=roles,
|
||||||
is_admin=is_admin,
|
is_admin=is_admin,
|
||||||
@ -1156,6 +1161,10 @@ class LdapCherry(object):
|
|||||||
custom_js=self.custom_js,
|
custom_js=self.custom_js,
|
||||||
notifications=self._empty_notification(),
|
notifications=self._empty_notification(),
|
||||||
)
|
)
|
||||||
|
except NameError:
|
||||||
|
raise TemplateRenderError(exceptions.text_error_template().render())
|
||||||
|
|
||||||
|
return glued_template
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@exception_decorator
|
@exception_decorator
|
||||||
|
@ -217,6 +217,11 @@ class GroupDoesntExist(Exception):
|
|||||||
" in backend '" + backend + "'"
|
" in backend '" + backend + "'"
|
||||||
|
|
||||||
|
|
||||||
|
class TemplateRenderError(Exception):
|
||||||
|
def __init__(self, error):
|
||||||
|
self.log = "Template Render Error: " + error
|
||||||
|
|
||||||
|
|
||||||
def exception_decorator(func):
|
def exception_decorator(func):
|
||||||
def ret(self, *args, **kwargs):
|
def ret(self, *args, **kwargs):
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user