def default(self): from decanter.api.interface import role connection = self.pargs.connection db.init_connection({ 'SQLALCHEMY_DATABASE_URI': connection, 'SQLALCHEMY_ECHO': True }) sys.stdout.write('Role Name: ') name = raw_input().strip() sys.stdout.write('Role Description: ') description = raw_input().strip() role.create(name, description)
def default(self): from decanter.api.interface import user, role connection = self.pargs.connection db.init_connection({ 'SQLALCHEMY_DATABASE_URI': connection, 'SQLALCHEMY_ECHO': True }) sys.stdout.write('Username: '******'Email: ') email = raw_input().strip() while True: password = getpass('Enter password: '******'Reenter password: '******'Passwords must match!\n\n') continue break while True: sys.stdout.write('Comma Separated List of User Roles: ') rs = raw_input().strip() roles = list() success = True for r in rs.split(','): r = r.strip() ro = role.get_by_name(r) if not ro: success = False sys.stdout.write('Unknown role: %s\n\n' % r) continue roles.append(ro) if success: break usr = user.create(username, email, password, roles=roles) print "User %s created" % usr
def default(self): connection = self.pargs.connection db.init_connection({ 'SQLALCHEMY_DATABASE_URI': connection, 'SQLALCHEMY_ECHO': True }) try: schema = self.pargs.schema drop = 'DROP SCHEMA IF EXISTS "%s" CASCADE;' drop %= schema db.session.execute(drop) db.session.execute('CREATE SCHEMA "%s";' % schema) db.session.execute('SET search_path TO "%s";' % schema) db.session.execute(self.types()) db.session.execute(self.sql()) db.session.commit() finally: db.session.remove()