Only define Agent if it doesn't exists yet
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 14 Oct 2016 17:49:59 +0200
changeset 1844 f5490600f552
parent 1843 4cec18e07edf
child 1845 5ec73e5b8383
Only define Agent if it doesn't exists yet When the seda cube is used from saem_ref, an Agent type is already provided by the prov cube. We should probably to that differently at some point, but that is enough to move on for now.
schema/__init__.py
--- a/schema/__init__.py	Fri Oct 14 17:48:49 2016 +0200
+++ b/schema/__init__.py	Fri Oct 14 17:49:59 2016 +0200
@@ -15,6 +15,7 @@
 # with this program. If not, see <http://www.gnu.org/licenses/>.
 """cubicweb-seda schema"""
 
+from yams.reader import context
 from yams.buildobjs import EntityType, RelationType, RelationDefinition
 from yams.buildobjs import String
 
@@ -76,14 +77,6 @@
     inlined = True
 
 
-class Agent(EntityType):
-    """An agent is something that bears some form of responsibility for an
-    activity taking place, for the existence of an entity, or for another
-    agent's activity.
-    """
-    name = String(required=True, fulltextindexed=True)
-
-
 class container(RelationType):
     __permissions__ = {'add': (), 'delete': (), 'read': ()}
     cardinality = '1*'
@@ -124,6 +117,15 @@
 kind.indexed = True
 
 
+if 'Agent' not in context.defined:
+    class Agent(EntityType):
+        """An agent is something that bears some form of responsibility for an
+        activity taking place, for the existence of an entity, or for another
+        agent's activity.
+        """
+        name = String(required=True, fulltextindexed=True)
+
+
 def post_build_callback(schema):
     from cubes.seda import seda_profile_container_def, iter_all_rdefs