entity.py
changeset 7206 2723c52a0795
parent 7177 0f2905cbe443
parent 7200 81fd6e40a6a8
child 7216 6053bf221fa9
--- a/entity.py	Thu Apr 07 00:27:47 2011 +0200
+++ b/entity.py	Mon Apr 11 20:43:30 2011 +0200
@@ -263,8 +263,16 @@
         relations = []
         restrictions = set()
         pending_relations = []
+        eschema = cls.e_schema
         for attr, value in kwargs.items():
-            if isinstance(value, (tuple, list, set, frozenset)):
+            if attr.startswith('reverse_'):
+                attr = attr[len('reverse_'):]
+                role = 'object'
+            else:
+                role = 'subject'
+            assert eschema.has_relation(attr, role)
+            rschema = eschema.subjrels[attr] if role == 'subject' else eschema.objrels[attr]
+            if not rschema.final and isinstance(value, (tuple, list, set, frozenset)):
                 if len(value) == 1:
                     value = iter(value).next()
                 else: