Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
0
 def delete_view(self, name):
     'Delete a view given a name.'
     yield View.deleteAll(where=['name = ?', name])
     defer.returnValue(True)