Esempio n. 1
0
class Backend(object):
    def __init__(self, opt):
        if 'plugin' not in opt:
            raise ValueError("no plugin selected")
        self.params = opt;
        self.backend = Plugin().load("plugins/Backend_"+opt['plugin']+".py")
        self.backend.constructor(self.params)

    def alreadyExist(self, key):
        res = self.backend.alreadyExist(key);
        if not isinstance(res, bool):
            raise TypeError('issues with the plugin: '+self.params['plugin']);
        else:
            return res;

    def put(self, key, obj):
        self.backend.put(key, obj);