Exemplo n.º 1
0
def set_config(plugin_name,config):
    _config = cache.client.get('xcat.plugins.config',{})
    pl_ar = models.Plugins.get(models.Plugins.name == plugin_name)
    pl_ar.config = Json.encode(config)
    pl_ar.save()
    _config[plugin_name] = config
    cache.client.set('xcat.plugins.config',_config)
Exemplo n.º 2
0
    def set(self, key, val, left_time=0, callback=None):
        is_persistence = False
        if -1 == left_time:
            is_persistence = True
            left_time = 0

        ret = yield gen.Task(self._conn.set, str(key), val, left_time)
        if callback:
            callback(ret)

        # 需要持久化,写入数据表
        if is_persistence:
            model = MemcacheModel.select().where(MemcacheModel.key == key)

            if 1 == (yield gen.Task(model.count)):
                ar = yield gen.Task(model.get)
            else:
                ar = MemcacheModel()
                ar.key = key

            ar.value = Json.encode(val)
            yield gen.Task(ar.save)
Exemplo n.º 3
0
    def set(self, key, val, left_time=0, callback=None):
        is_persistence = False
        if -1 == left_time:
            is_persistence = True
            left_time = 0

        ret = yield gen.Task(self._conn.set, str(key), val, left_time)
        if callback:
            callback(ret)
        
        # 需要持久化,写入数据表
        if is_persistence:
           model = MemcacheModel.select().where(MemcacheModel.key == key)
           
           if 1 == (yield gen.Task(model.count)):
               ar = yield gen.Task(model.get)
           else:
               ar = MemcacheModel()
               ar.key = key
           
           ar.value = Json.encode(val)
           yield gen.Task(ar.save)
Exemplo n.º 4
0
        handlers = []
        for v in plugin._handlers:
            handlers.append(
                v.__module__ + '.' + v.__name__
            )

        ui_modules = []
        for v in plugin._ui_modules:
            _application.ui_modules[v.__name__] = v
            ui_modules.append(
                v.__module__ + '.' + v.__name__
            )

        pl = models.Plugins()
        pl.name        = name
        pl.bind        = Json.encode(register._targets)
        pl.handlers    = Json.encode(handlers)
        pl.ui_modules  = Json.encode(ui_modules)

        if plugin.get_form() :
            pl.config = Json.encode(plugin.get_form().get_default_values())
        pl.save()

        # 安装路由
        if len(plugin._handlers) > 0 :
            from xcat.web import Application
            cache.client.set(Application._sync_key,Date.time())

        reset()
        
class Register(object):
Exemplo n.º 5
0
 def set_token(self, access_token):
     self.access_token = Json.encode(access_token)