def populate(engine, interactive=True): Base.metadata.create_all(engine) session = DBSession() user_perm = Permission(name=u'user_view') admin_perm = Permission(name=u'admin_view') download_perm = Permission(name=u'download_releasefile') upload_perm = Permission(name=u'upload_releasefile') session.add(user_perm) session.add(upload_perm) session.add(download_perm) session.add(admin_perm) admin_group = Group(name=u'admin') admin_group.permissions.append(user_perm) admin_group.permissions.append(download_perm) admin_group.permissions.append(upload_perm) admin_group.permissions.append(admin_perm) session.add(admin_group) user_group = Group(name=u'developer') user_group.permissions.append(user_perm) user_group.permissions.append(download_perm) user_group.permissions.append(upload_perm) session.add(user_group) pip_group = Group(name=u'installer') pip_group.permissions.append(download_perm) session.add(pip_group) if interactive: login = (input('administrator login [admin]:') or 'admin') password = (input('administrator password [changeme]:') or 'changeme') email = (input('administrator email [[email protected]]') or '*****@*****.**') piplogin = (input('installer login [pip]:') or 'pip') pippassword = (input('installer password [changeme]:') or 'changeme') else: login = '******' password = '******' email = '*****@*****.**' piplogin = '******' pippassword = '******' admin = User(login=unicode(login), password=unicode(password), email=unicode(email)) admin.groups.append(admin_group) session.add(admin) pip = User(login=unicode(piplogin), password=unicode(pippassword), ) pip.groups.append(pip_group) session.add(pip) session.commit()
def setUp(self): super(AccountTestCase, self).setUp() import uuid from pyshop.models import User, Group self.account_login = unicode(uuid.uuid4()) u = User(login=self.account_login, password=u'secret') u.groups.append(Group.by_name(self.session, u'developer')) self.session.add(u) self.session.flush() self.account_id = u.id self.account_todelete = [self.account_id]
def _set_password(self, password): self._password = unicode(crypt.encode(password))
def _set_password(self, password): # we want to store this in the database as unicode self._password = unicode(self.hash_password(password))