def __init__(self, controller=None): globals()['ctrl'] = controller log.debug("Initialized controller") try: self.urls = ("/(.*)", "Restapi") sys.argv[1:] = ['8888'] except ValueError, err: raise SynapseException('Wrong port (%s)' % err)
def process_request(self, path, action): msg = {} try: path.lstrip('/') path_parts = path.split('/') msg['action'] = action msg['collection'] = path_parts[0] if len(path_parts) > 1: id = path_parts[1] msg['id'] = id if len(web.data()): msg['attributes'] = json.loads(web.data()) log.debug('REST Msg: %s' % msg) except IndexError, err: return err
def start(self): log.debug("Starting REST API") app = web.application(self.urls, globals()) app.run()