Browse Source

added test user to db init

master
Holger Frey 7 years ago
parent
commit
96c1717eac
  1. 2
      development.ini
  2. 15
      ordr2/scripts/initializedb.py

2
development.ini

@ -16,7 +16,7 @@ pyramid.includes =
pyramid_debugtoolbar pyramid_debugtoolbar
pyramid_jinja2 pyramid_jinja2
sqlalchemy.url = sqlite:///%(here)s/ordr2.sqlite sqlalchemy.url = sqlite:///%(here)s/ordr2_development.sqlite
passlib.config = %(here)s/passlib.ini passlib.config = %(here)s/passlib.ini
# automatic CSRF token validation on each POST resquest # automatic CSRF token validation on each POST resquest

15
ordr2/scripts/initializedb.py

@ -17,7 +17,7 @@ from ..models import (
get_session_factory, get_session_factory,
get_tm_session, get_tm_session,
) )
# from ..models import MyModel from ..models.account import User, Role, passlib_context
def usage(argv): def usage(argv):
@ -40,8 +40,17 @@ def main(argv=sys.argv):
session_factory = get_session_factory(engine) session_factory = get_session_factory(engine)
passlib_context.load_path(settings['passlib.config'])
with transaction.manager: with transaction.manager:
dbsession = get_tm_session(session_factory, transaction.manager) dbsession = get_tm_session(session_factory, transaction.manager)
# model = MyModel(name='one', value=1) user = User(
# dbsession.add(model) username='HolgerFrey',
first_name='Holger',
last_name='Frey',
email='frey@imtek.de',
role=Role.ADMIN
)
user.set_password('holgi')
dbsession.add(user)