def post(self): try: school_data = api.payload print(school_data) post('data', api.payload) return 'fees: ' + str(fees) except Exception: raise Exception('Exception in finding fee')
def get(self, data): try: with ruleset('test'): @when_all( (m.school == 'GANDHI SCHOOL') & (m.location == 'JAIPUR')) def school_abc(c): global fees fees = 1000 print('fees:', fees) post('test', data) return 'fees: ' + str(fees), 201 except Exception: raise Exception("Issue in finding user")
def quick_post_event(r, f): """ Post an event from a colon separated triple string. Triple strings of the form: "a subject: predicate : and object" """ _statement = [t.strip() for t in f.split(':')] if len(_statement) == 3: subj = _statement[0] pred = _statement[1] obj = _statement[2] #print('..', r, spo(subj, pred, obj ),'..' ) try: post(r, SPO(subj, pred, obj)) except MessageObservedException: warnings.warn(f"Post event error with {_statement}.") elif len(_statement) == 2: post(r, {_statement[0]: _statement[1]})
def add(self, data): try: """ if _main_host._ruleset_directory is not None: _main_host._ruleset_directory.clear() """ with ruleset('data'): @when_all( (m.school == 'GANDHI SCHOOL') & (m.location == 'JAIPUR')) def school_abc(c): global fees fees = 1000 @when_all((m.school == 'DDU SCHOOL') & (m.location == 'DELHI')) def school_abc(c): global fees fees = 2000 post('data', data) return {'Fees': fees}, 201 except Exception: raise Exception("Issue in adding user")
from durable.lang import ruleset, when_all, m, post with ruleset('test'): @when_all(m.subject == 'World') def say_hello(c): print('Hello {0}'.format(c.m.subject)) @when_all(m.subject == 'World1') def say_hello1(c): print('Hello1 {0}'.format(c.m.subject)) post('test', {'subject': 'World'}) post('test', {'subject': 'World1'})
def listen(self, message): # Extract meaning from the message post(self.current_state, {'subject': message})