def view_exists(self, name): 'Does a view with this name exist?' view = yield View.find(where=['name = ?', name]) exists = False if view: exists = True defer.returnValue(exists)
def get_view(self, name): 'Retrieve a view definition given a name' view = yield View.find(where=['name = ?', name], limit=1) if not view: defer.returnValue([]) # XXX(ray): Emulated behavior of tornadoredis items = json.loads(view.definition) defer.returnValue(items)
def set_view(self, name, values): 'Create or update a view. This does a complete overwrite.' view = yield View.find(where=['name = ?', name]) if view: # Do an update. view.definition = json.dumps(values) view.update() else: # Do an insert. definition = json.dumps(values) yield View(name=name, definition=definition).save() defer.returnValue(True)
def get_views(self): """Return a list of all views stored in the system. This takes no parameters. """ try: views = yield View.find() defer.returnValue([v.name for v in views]) except pyodbc.Error: logging.error(pprint.pformat(Registry.DBPOOL.__dict__)) msg = "" for conn in Registry.DBPOOL.connections: msg += "%s, " % (pprint.pformat(Registry.DBPOOL.connections[conn])) logging.error('Connections: [%s]' % msg)
def delete_view(self, name): 'Delete a view given a name.' yield View.deleteAll(where=['name = ?', name]) defer.returnValue(True)