def on_grant(self): for db_cfg in self.config['databases']: db = Database() db.name = db_cfg['name'] for user_cfg in self.config['users']: user = User() user.name = user_cfg['name'] user.password = user_cfg['password'] user.host = '%' self.db.query_grant(user, db) self.context.notify('info', _('Permissions granted.'))
def on_grant(self): for db_cfg in self.config['databases']: db = Database() db.name = db_cfg['name'] for user_cfg in self.config['users']: user = User() user.name = user_cfg['name'] user.password = user_cfg['password'] user.host = '%' self.db.query_grant(user, db) self.context.notify('info', _('Permissions granted.'))
def on_grant(self): for db_cfg in self.config["databases"]: db = Database() db.name = db_cfg["name"] for user_cfg in self.config["users"]: user = User() user.name = user_cfg["name"] user.password = user_cfg["password"] user.host = "%" self.db.query_grant(user, db) self.context.notify("info", _("Permissions granted."))
self.config['password'] = str(uuid.uuid4()) try: self.db.query_create(self.config['name']) except Exception, e: self.context.notify('error', str(e)) return self.config['created'] = True db = Database() db.name = self.config['name'] user = User() user.name = self.config['username'] user.password = self.config['password'] user.host = 'localhost' try: self.db.query_create_user(user) except Exception, e: self.db.query_drop(db) self.context.notify('error', str(e)) return self.db.query_grant(user, db) self.refresh() @on('delete', 'click') def on_delete(self): db = Database() db.name = self.config['name']
password = self.find('db-password').value for user in self.db.query_users(): if user.name == username: self.context.notify('error', _('This username is already used')) return user_cfg = { 'name': username, 'password': password, } user = User() user.name = user_cfg['name'] user.password = user_cfg['password'] user.host = '%' try: self.db.query_create_user(user) except Exception, e: self.context.notify('error', str(e)) return self.config['users'].append(user_cfg) self.on_grant() self.refresh() self.try_save() @on('grant', 'click') def on_grant(self):
return username = self.find('db-username').value for user in self.db.query_users(): if user.name == username: self.context.notify('error', _('This username is already used')) return user_cfg = { 'name': username, 'password': str(uuid.uuid4()), } user = User() user.name = user_cfg['name'] user.password = user_cfg['password'] user.host = '%' try: self.db.query_create_user(user) except Exception, e: self.context.notify('error', str(e)) return self.config['users'].append(user_cfg) self.on_grant() self.refresh() self.try_save() @on('grant', 'click') def on_grant(self):
self.context.launch("configure-plugin", plugin=self.db) return username = self.find("db-username").value password = self.find("db-password").value for user in self.db.query_users(): if user.name == username: self.context.notify("error", _("This username is already used")) return user_cfg = {"name": username, "password": password} user = User() user.name = user_cfg["name"] user.password = user_cfg["password"] user.host = "%" try: self.db.query_create_user(user) except Exception, e: self.context.notify("error", str(e)) return self.config["users"].append(user_cfg) self.on_grant() self.refresh() self.try_save() @on("grant", "click") def on_grant(self):