57 'initial_state', 'default_workflow', |
57 'initial_state', 'default_workflow', |
58 'allowed_transition', 'destination_state', |
58 'allowed_transition', 'destination_state', |
59 'from_state', 'to_state', 'condition', |
59 'from_state', 'to_state', 'condition', |
60 'subworkflow', 'subworkflow_state', 'subworkflow_exit', |
60 'subworkflow', 'subworkflow_state', 'subworkflow_exit', |
61 )) |
61 )) |
62 SYSTEM_RTYPES = set(('in_group', 'require_group', |
62 SYSTEM_RTYPES = set(('in_group', 'require_group', 'require_permission', |
63 # cwproperty |
63 # cwproperty |
64 'for_user', |
64 'for_user', |
65 )) | WORKFLOW_RTYPES |
65 )) | WORKFLOW_RTYPES |
66 NO_I18NCONTEXT = META_RTYPES | WORKFLOW_RTYPES |
66 NO_I18NCONTEXT = META_RTYPES | WORKFLOW_RTYPES |
|
67 NO_I18NCONTEXT.add('require_permission') |
67 |
68 |
68 SKIP_COMPOSITE_RELS = [('cw_source', 'subject')] |
69 SKIP_COMPOSITE_RELS = [('cw_source', 'subject')] |
69 |
70 |
70 # set of entity and relation types used to build the schema |
71 # set of entity and relation types used to build the schema |
71 SCHEMA_TYPES = set(( |
72 SCHEMA_TYPES = set(( |
82 |
83 |
83 WORKFLOW_TYPES = set(('Transition', 'State', 'TrInfo', 'Workflow', |
84 WORKFLOW_TYPES = set(('Transition', 'State', 'TrInfo', 'Workflow', |
84 'WorkflowTransition', 'BaseTransition', |
85 'WorkflowTransition', 'BaseTransition', |
85 'SubWorkflowExitPoint')) |
86 'SubWorkflowExitPoint')) |
86 |
87 |
87 INTERNAL_TYPES = set(('CWProperty', 'CWCache', 'ExternalUri', |
88 INTERNAL_TYPES = set(('CWProperty', 'CWPermission', 'CWCache', 'ExternalUri', |
88 'CWSource', 'CWSourceHostConfig', 'CWSourceSchemaConfig')) |
89 'CWSource', 'CWSourceHostConfig', 'CWSourceSchemaConfig')) |
89 |
90 |
90 |
91 |
91 _LOGGER = getLogger('cubicweb.schemaloader') |
92 _LOGGER = getLogger('cubicweb.schemaloader') |
92 |
93 |
1171 set_log_methods(BootstrapSchemaLoader, getLogger('cubicweb.bootstrapschemaloader')) |
1172 set_log_methods(BootstrapSchemaLoader, getLogger('cubicweb.bootstrapschemaloader')) |
1172 set_log_methods(RQLExpression, getLogger('cubicweb.schema')) |
1173 set_log_methods(RQLExpression, getLogger('cubicweb.schema')) |
1173 |
1174 |
1174 # _() is just there to add messages to the catalog, don't care about actual |
1175 # _() is just there to add messages to the catalog, don't care about actual |
1175 # translation |
1176 # translation |
1176 MAY_USE_TEMPLATE_FORMAT = set(('managers',)) |
1177 PERM_USE_TEMPLATE_FORMAT = _('use_template_format') |
1177 NEED_PERM_FORMATS = [_('text/cubicweb-page-template')] |
1178 NEED_PERM_FORMATS = [_('text/cubicweb-page-template')] |
1178 |
1179 |
1179 @monkeypatch(FormatConstraint) |
1180 @monkeypatch(FormatConstraint) |
1180 def vocabulary(self, entity=None, form=None): |
1181 def vocabulary(self, entity=None, form=None): |
1181 cw = None |
1182 cw = None |
1186 if cw is not None: |
1187 if cw is not None: |
1187 if hasattr(cw, 'write_security'): # test it's a session and not a request |
1188 if hasattr(cw, 'write_security'): # test it's a session and not a request |
1188 # cw is a server session |
1189 # cw is a server session |
1189 hasperm = not cw.write_security or \ |
1190 hasperm = not cw.write_security or \ |
1190 not cw.is_hook_category_activated('integrity') or \ |
1191 not cw.is_hook_category_activated('integrity') or \ |
1191 cw.user.matching_groups(MAY_USE_TEMPLATE_FORMAT) |
1192 cw.user.has_permission(PERM_USE_TEMPLATE_FORMAT) |
1192 else: |
1193 else: |
1193 hasperm = cw.user.matching_groups(MAY_USE_TEMPLATE_FORMAT) |
1194 hasperm = cw.user.has_permission(PERM_USE_TEMPLATE_FORMAT) |
1194 if hasperm: |
1195 if hasperm: |
1195 return self.regular_formats + tuple(NEED_PERM_FORMATS) |
1196 return self.regular_formats + tuple(NEED_PERM_FORMATS) |
1196 return self.regular_formats |
1197 return self.regular_formats |
1197 |
1198 |
1198 # XXX monkey patch PyFileReader.import_erschema until bw_normalize_etype is |
1199 # XXX monkey patch PyFileReader.import_erschema until bw_normalize_etype is |