equal
deleted
inserted
replaced
259 """ |
259 """ |
260 rql = 'INSERT %s X' % cls.__regid__ |
260 rql = 'INSERT %s X' % cls.__regid__ |
261 relations = [] |
261 relations = [] |
262 restrictions = set() |
262 restrictions = set() |
263 pending_relations = [] |
263 pending_relations = [] |
|
264 eschema = cls.e_schema |
264 for attr, value in kwargs.items(): |
265 for attr, value in kwargs.items(): |
265 if isinstance(value, (tuple, list, set, frozenset)): |
266 if attr.startswith('reverse_'): |
|
267 attr = attr[len('reverse_'):] |
|
268 role = 'object' |
|
269 else: |
|
270 role = 'subject' |
|
271 assert eschema.has_relation(attr, role) |
|
272 rschema = eschema.subjrels[attr] if role == 'subject' else eschema.objrels[attr] |
|
273 if not rschema.final and isinstance(value, (tuple, list, set, frozenset)): |
266 if len(value) == 1: |
274 if len(value) == 1: |
267 value = iter(value).next() |
275 value = iter(value).next() |
268 else: |
276 else: |
269 del kwargs[attr] |
277 del kwargs[attr] |
270 pending_relations.append( (attr, value) ) |
278 pending_relations.append( (attr, value) ) |