--- a/hooks/syncschema.py Sat Jun 11 09:22:25 2011 +0200
+++ b/hooks/syncschema.py Wed Jun 15 17:16:19 2011 +0200
@@ -577,7 +577,8 @@
elif lastrel:
DropRelationTable(session, str(rschema))
# then update the in-memory schema
- rschema.del_relation_def(rdef.subject, rdef.object)
+ if rdef.subject not in ETYPE_NAME_MAP and rdef.object not in ETYPE_NAME_MAP:
+ rschema.del_relation_def(rdef.subject, rdef.object)
# if this is the last relation definition of this type, drop associated
# relation type
if lastrel and not session.deleted_in_transaction(rschema.eid):
@@ -588,8 +589,10 @@
#
# Note: add_relation_def takes a RelationDefinition, not a
# RelationDefinitionSchema, needs to fake it
- self.rdef.name = str(self.rdef.rtype)
- self.session.vreg.schema.add_relation_def(self.rdef)
+ rdef = self.rdef
+ rdef.name = str(rdef.rtype)
+ if rdef.subject not in ETYPE_NAME_MAP and rdef.object not in ETYPE_NAME_MAP:
+ self.session.vreg.schema.add_relation_def(rdef)
@@ -885,7 +888,7 @@
if name in CORE_TYPES:
raise ValidationError(self.entity.eid, {None: self._cw._('can\'t be deleted')})
# delete every entities of this type
- if not name in ETYPE_NAME_MAP:
+ if name not in ETYPE_NAME_MAP:
self._cw.execute('DELETE %s X' % name)
MemSchemaCWETypeDel(self._cw, etype=name)
DropTable(self._cw, table=SQL_PREFIX + name)
@@ -1069,6 +1072,8 @@
return
subjtype = entity.stype.name
objtype = entity.otype.name
+ if subjtype in ETYPE_NAME_MAP or objtype in ETYPE_NAME_MAP:
+ return
rschema = self._cw.vreg.schema[entity.rtype.name]
# note: do not access schema rdef here, it may be added later by an
# operation