def create(ac_code, class_code): run = self.prep_runtime() acth = run.ACCESSCONTROL_THEORY permitted, errors = run.insert(ac_code, target=acth) self.assertTrue(permitted, "Error in access control policy: {}".format( agnostic.iterstr(errors))) clsth = run.CLASSIFY_THEORY permitted, errors = run.insert(class_code, target=clsth) self.assertTrue(permitted, "Error in classifier policy: {}".format( agnostic.iterstr(errors))) return run
def create(self, action_code, class_code, theories=None): run = self.prep_runtime(theories=theories) actth = self.ACTION_THEORY permitted, errors = run.insert(action_code, target=actth) self.assertTrue(permitted, "Error in action policy: {}".format( agnostic.iterstr(errors))) defth = self.DEFAULT_THEORY permitted, errors = run.insert(class_code, target=defth) self.assertTrue(permitted, "Error in classifier policy: {}".format( agnostic.iterstr(errors))) return run
def create(ac_code, class_code): run = self.prep_runtime() acth = run.ACCESSCONTROL_THEORY permitted, errors = run.insert(ac_code, target=acth) self.assertTrue( permitted, "Error in access control policy: {}".format( agnostic.iterstr(errors))) clsth = run.CLASSIFY_THEORY permitted, errors = run.insert(class_code, target=clsth) self.assertTrue( permitted, "Error in classifier policy: {}".format( agnostic.iterstr(errors))) return run
def create(self, action_code, class_code, theories=None): run = self.prep_runtime(theories=theories) actth = self.ACTION_THEORY permitted, errors = run.insert(action_code, target=actth) self.assertTrue( permitted, "Error in action policy: {}".format(agnostic.iterstr(errors))) defth = self.DEFAULT_THEORY permitted, errors = run.insert(class_code, target=defth) self.assertTrue( permitted, "Error in classifier policy: {}".format(agnostic.iterstr(errors))) return run
def prepush_processor(self, data, dataindex, type=None): """Called before push. Takes as input the DATA that the receiver needs and returns the payload for the message. If this is a regular publication message, make the payload just the delta; otherwise, make the payload the entire table. """ # This routine basically ignores DATA and sends a delta # of the self.prior_state and self.state, for the DATAINDEX # part of the state. self.log("prepush_processor: dataindex <%s> data: %s", dataindex, data) # if not a regular publication, just return the original data if type != 'pub': self.log("prepush_processor: returned original data") if type == 'sub': # Always want to send initialization of [] if data is None: return [] else: return data return data # grab deltas to_add = self.state_set_diff(self.state, self.prior_state, dataindex) to_del = self.state_set_diff(self.prior_state, self.state, dataindex) self.log("to_add: %s", to_add) self.log("to_del: %s", to_del) # create Events result = [] for row in to_add: formula = compile.Literal.create_from_table_tuple(dataindex, row) event = agnostic.Event(formula=formula, insert=True) result.append(event) for row in to_del: formula = compile.Literal.create_from_table_tuple(dataindex, row) event = agnostic.Event(formula=formula, insert=False) result.append(event) if len(result) == 0: # Policy engine expects an empty update to be an init msg # So if delta is empty, return None, which signals # the message should not be sent. result = None text = "None" else: text = agnostic.iterstr(result) self.log("prepush_processor for <%s> returning with %s items", dataindex, text) return result