def bootstrap(command, conf, vars): """Place any commands to setup wiki20 here""" # <websetup.bootstrap.before.auth from sqlalchemy.exc import IntegrityError try: u = model.User() u.user_name = 'manager' u.display_name = 'Example manager' u.email_address = '*****@*****.**' u.password = '******' model.DBSession.add(u) g = model.Group() g.group_name = 'managers' g.display_name = 'Managers Group' g.users.append(u) model.DBSession.add(g) p = model.Permission() p.permission_name = 'manage' p.description = 'This permission gives an administrative right' p.groups.append(g) model.DBSession.add(p) u1 = model.User() u1.user_name = 'editor' u1.display_name = 'Example editor' u1.email_address = '*****@*****.**' u1.password = '******' # tbl_register = model.Register(first_name="sdk",user_name="sdk",password="******",email="[email protected]",contact_no="123") # model.DBSession.add(tbl_register) model.DBSession.add(u1) page = model.Page(pagename="FrontPage", data="initial data") model.DBSession.add(page) model.DBSession.flush() transaction.commit() except IntegrityError: print('Warning, there was a problem adding your auth data, ' 'it may have already been added:') import traceback print(traceback.format_exc()) transaction.abort() print('Continuing with bootstrapping...')
def bootstrap(command, conf, vars): """Place any commands to setup wiki20 here""" # <websetup.bootstrap.before.auth from sqlalchemy.exc import IntegrityError try: u = model.User() u.user_name = u'manager' u.display_name = u'Example manager' u.email_address = u'*****@*****.**' u.password = u'managepass' model.DBSession.add(u) g = model.Group() g.group_name = u'managers' g.display_name = u'Managers Group' g.users.append(u) model.DBSession.add(g) p = model.Permission() p.permission_name = u'manage' p.description = u'This permission give an administrative right to the bearer' p.groups.append(g) model.DBSession.add(p) u1 = model.User() u1.user_name = u'editor' u1.display_name = u'Example editor' u1.email_address = u'*****@*****.**' u1.password = u'editpass' model.DBSession.add(u1) page = model.Page("FrontPage", "initial data") model.DBSession.add(page) model.DBSession.flush() transaction.commit() except IntegrityError: print 'Warning, there was a problem adding your auth data, it may have already been added:' import traceback print traceback.format_exc() transaction.abort() print 'Continuing with bootstrapping...'
def setup_app(command, conf, vars): """Place any commands to setup wiki20 here""" load_environment(conf.global_conf, conf.local_conf) # Load the models from wiki20 import model print "Creating tables" model.metadata.create_all(bind=config['pylons.app_globals'].sa_engine) # Create the initial data print "Creating initial data" page = model.Page("FrontPage", "initial data") model.DBSession.add(page) transaction.commit() print "Successfully setup"