do not check for use template permission when session is super session or integrity hooks are deactivated stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 02 Mar 2010 15:58:39 +0100
branchstable
changeset 4757 5d937aeaa6fb
parent 4756 a2c73b272c9b
child 4758 0efdcf0fa4c7
do not check for use template permission when session is super session or integrity hooks are deactivated
schema.py
--- a/schema.py	Tue Mar 02 15:57:32 2010 +0100
+++ b/schema.py	Tue Mar 02 15:58:39 2010 +0100
@@ -1082,8 +1082,16 @@
         cw = entity._cw
     elif form is not None:
         cw = form._cw
-    if cw is not None and cw.user.has_permission(PERM_USE_TEMPLATE_FORMAT):
-        return self.regular_formats + tuple(NEED_PERM_FORMATS)
+    if cw is not None:
+        if hasattr(cw, 'is_super_session'):
+            # cw is a server session
+            hasperm = cw.is_super_session or \
+                      not cw.vreg.config.is_hook_category_activated('integrity') or \
+                      cw.user.has_permission(PERM_USE_TEMPLATE_FORMAT)
+        else:
+            hasperm = cw.user.has_permission(PERM_USE_TEMPLATE_FORMAT)
+        if hasperm:
+            return self.regular_formats + tuple(NEED_PERM_FORMATS)
     return self.regular_formats
 
 # XXX monkey patch PyFileReader.import_erschema until bw_normalize_etype is