[schema] introduce some new sets categorizing entity/relation types and benefits from them where possible
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 01 Oct 2010 15:45:00 +0200
changeset 6377 3bb415310d4f
parent 6376 f8662240ed4d
child 6378 5a86a0c147bd
[schema] introduce some new sets categorizing entity/relation types and benefits from them where possible
devtools/__init__.py
schema.py
web/views/__init__.py
web/views/primary.py
--- a/devtools/__init__.py	Fri Oct 01 11:24:21 2010 +0200
+++ b/devtools/__init__.py	Fri Oct 01 15:45:00 2010 +0200
@@ -35,30 +35,19 @@
 
 # db auto-population configuration #############################################
 
-SYSTEM_ENTITIES = schema.SCHEMA_TYPES | set((
-    'CWGroup', 'CWUser', 'CWProperty',
-    'Workflow', 'State', 'BaseTransition', 'Transition', 'WorkflowTransition',
-    'TrInfo', 'SubWorkflowExitPoint',
-    ))
-
-SYSTEM_RELATIONS = schema.META_RTYPES | set((
-    # workflow related
-    'workflow_of', 'state_of', 'transition_of', 'initial_state', 'default_workflow',
-    'allowed_transition', 'destination_state', 'from_state', 'to_state',
-    'condition', 'subworkflow', 'subworkflow_state', 'subworkflow_exit',
-    'custom_workflow', 'in_state', 'wf_info_for',
-    # cwproperty
-    'for_user',
-    # schema definition
-    'specializes',
-    'relation_type', 'from_entity', 'to_entity',
-    'constrained_by', 'cstrtype', 'widget',
-    'read_permission', 'update_permission', 'delete_permission', 'add_permission',
-    # permission
-    'in_group', 'require_group', 'require_permission',
-    # deducted from other relations
-    'primary_email',
-    ))
+SYSTEM_ENTITIES = (schema.SCHEMA_TYPES
+                   | schema.INTERNAL_TYPES
+                   | schema.WORKFLOW_TYPES
+                   | set(('CWGroup', 'CWUser',))
+                   )
+SYSTEM_RELATIONS = (schema.META_RTYPES
+                    | schema.WORKFLOW_RTYPES
+                    | schema.WORKFLOW_DEF_RTYPES
+                    | schema.SYSTEM_RTYPES
+                    | schema.SCHEMA_TYPES
+                    | set(('primary_email', # deducted from other relations
+                           ))
+                    )
 
 # content validation configuration #############################################
 
--- a/schema.py	Fri Oct 01 11:24:21 2010 +0200
+++ b/schema.py	Fri Oct 01 15:45:00 2010 +0200
@@ -52,13 +52,23 @@
     'eid', 'creation_date', 'modification_date', 'has_text', 'cwuri',
     ))
 WORKFLOW_RTYPES = set(('custom_workflow', 'in_state', 'wf_info_for'))
-SYSTEM_RTYPES = set(('require_permission',)) | WORKFLOW_RTYPES
+WORKFLOW_DEF_RTYPES = set(('workflow_of', 'state_of', 'transition_of',
+                           'initial_state', 'default_workflow',
+                           'allowed_transition', 'destination_state',
+                           'from_state', 'to_state', 'condition',
+                           'subworkflow', 'subworkflow_state', 'subworkflow_exit',
+                           ))
+SYSTEM_RTYPES = set(('in_group', 'require_group', 'require_permission',
+                     # cwproperty
+                     'for_user',
+                     )) | WORKFLOW_RTYPES
 
 # set of entity and relation types used to build the schema
 SCHEMA_TYPES = set((
     'CWEType', 'CWRType', 'CWAttribute', 'CWRelation',
     'CWConstraint', 'CWConstraintType', 'CWUniqueTogetherConstraint',
     'RQLExpression',
+    'specializes',
     'relation_type', 'from_entity', 'to_entity',
     'constrained_by', 'cstrtype',
     'constraint_of', 'relations',
@@ -70,7 +80,9 @@
                       'WorkflowTransition', 'BaseTransition',
                       'SubWorkflowExitPoint'))
 
-INTERNAL_TYPES = set(('CWProperty', 'CWPermission', 'CWCache', 'ExternalUri'))
+INTERNAL_TYPES = set(('CWProperty', 'CWPermission', 'CWCache', 'ExternalUri',
+                      'CWSource', 'CWSourceAlias',
+))
 
 
 _LOGGER = getLogger('cubicweb.schemaloader')
--- a/web/views/__init__.py	Fri Oct 01 11:24:21 2010 +0200
+++ b/web/views/__init__.py	Fri Oct 01 15:45:00 2010 +0200
@@ -15,9 +15,8 @@
 #
 # You should have received a copy of the GNU Lesser General Public License along
 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
-"""Views, forms, actions... for the CubicWeb web client
+"""Views, forms, actions... for the CubicWeb web client"""
 
-"""
 __docformat__ = "restructuredtext en"
 
 import os
--- a/web/views/primary.py	Fri Oct 01 11:24:21 2010 +0200
+++ b/web/views/primary.py	Fri Oct 01 15:45:00 2010 +0200
@@ -28,7 +28,7 @@
 from cubicweb.utils import support_args
 from cubicweb.selectors import match_kwargs
 from cubicweb.view import EntityView
-from cubicweb.schema import VIRTUAL_RTYPES, display_name
+from cubicweb.schema import META_RTYPES, VIRTUAL_RTYPES, display_name
 from cubicweb.web import uicfg
 
 
@@ -386,8 +386,8 @@
 ## default primary ui configuration ###########################################
 
 _pvs = uicfg.primaryview_section
-for rtype in ('eid', 'creation_date', 'modification_date', 'cwuri',
-              'is', 'is_instance_of', 'identity', 'owned_by', 'created_by',
-              'require_permission'):
+for rtype in META_RTYPES:
     _pvs.tag_subject_of(('*', rtype, '*'), 'hidden')
     _pvs.tag_object_of(('*', rtype, '*'), 'hidden')
+_pvs.tag_subject_of(('*', 'require_permission', '*'), 'hidden')
+_pvs.tag_object_of(('*', 'require_permission', '*'), 'hidden')