284 accepts = None # subject_relations + object_relations |
284 accepts = None # subject_relations + object_relations |
285 |
285 |
286 def call(self, session, fromeid, rtype, toeid): |
286 def call(self, session, fromeid, rtype, toeid): |
287 for eid in (fromeid, toeid): |
287 for eid in (fromeid, toeid): |
288 etype = session.describe(eid)[0] |
288 etype = session.describe(eid)[0] |
289 if not self.schema.eschema(etype).has_subject_relation(self.rtype): |
289 if self.rtype not in self.schema.eschema(etype).subjrels: |
290 return |
290 return |
291 if rtype in self.subject_relations: |
291 if rtype in self.subject_relations: |
292 meid, seid = fromeid, toeid |
292 meid, seid = fromeid, toeid |
293 else: |
293 else: |
294 assert rtype in self.object_relations |
294 assert rtype in self.object_relations |
310 |
310 |
311 def call(self, session, fromeid, rtype, toeid): |
311 def call(self, session, fromeid, rtype, toeid): |
312 eschema = self.schema.eschema(session.describe(fromeid)[0]) |
312 eschema = self.schema.eschema(session.describe(fromeid)[0]) |
313 execute = session.unsafe_execute |
313 execute = session.unsafe_execute |
314 for rel in self.subject_relations: |
314 for rel in self.subject_relations: |
315 if eschema.has_subject_relation(rel): |
315 if rel in eschema.subjrels: |
316 execute('SET R %s P WHERE X eid %%(x)s, P eid %%(p)s, ' |
316 execute('SET R %s P WHERE X eid %%(x)s, P eid %%(p)s, ' |
317 'X %s R, NOT R %s P' % (rtype, rel, rtype), |
317 'X %s R, NOT R %s P' % (rtype, rel, rtype), |
318 {'x': fromeid, 'p': toeid}, 'x') |
318 {'x': fromeid, 'p': toeid}, 'x') |
319 for rel in self.object_relations: |
319 for rel in self.object_relations: |
320 if eschema.has_object_relation(rel): |
320 if rel in eschema.objrels: |
321 execute('SET R %s P WHERE X eid %%(x)s, P eid %%(p)s, ' |
321 execute('SET R %s P WHERE X eid %%(x)s, P eid %%(p)s, ' |
322 'R %s X, NOT R %s P' % (rtype, rel, rtype), |
322 'R %s X, NOT R %s P' % (rtype, rel, rtype), |
323 {'x': fromeid, 'p': toeid}, 'x') |
323 {'x': fromeid, 'p': toeid}, 'x') |
324 |
324 |
325 |
325 |
334 |
334 |
335 def call(self, session, fromeid, rtype, toeid): |
335 def call(self, session, fromeid, rtype, toeid): |
336 eschema = self.schema.eschema(session.describe(fromeid)[0]) |
336 eschema = self.schema.eschema(session.describe(fromeid)[0]) |
337 execute = session.unsafe_execute |
337 execute = session.unsafe_execute |
338 for rel in self.subject_relations: |
338 for rel in self.subject_relations: |
339 if eschema.has_subject_relation(rel): |
339 if rel in eschema.subjrels: |
340 execute('DELETE R %s P WHERE X eid %%(x)s, P eid %%(p)s, ' |
340 execute('DELETE R %s P WHERE X eid %%(x)s, P eid %%(p)s, ' |
341 'X %s R' % (rtype, rel), |
341 'X %s R' % (rtype, rel), |
342 {'x': fromeid, 'p': toeid}, 'x') |
342 {'x': fromeid, 'p': toeid}, 'x') |
343 for rel in self.object_relations: |
343 for rel in self.object_relations: |
344 if eschema.has_object_relation(rel): |
344 if rel in eschema.objrels: |
345 execute('DELETE R %s P WHERE X eid %%(x)s, P eid %%(p)s, ' |
345 execute('DELETE R %s P WHERE X eid %%(x)s, P eid %%(p)s, ' |
346 'R %s X' % (rtype, rel), |
346 'R %s X' % (rtype, rel), |
347 {'x': fromeid, 'p': toeid}, 'x') |
347 {'x': fromeid, 'p': toeid}, 'x') |