def setup( dbh ): """ populate the database with basic, essential data """ if get_datalogger(): get_clsreg().sync() session.commit() dbsession = dbh.session() EK.bulk_update( ek_initlist, dbsession=dbsession ) Group.bulk_insert( essential_groups, dbsession=dbsession ) UserClass.bulk_insert( system_userclass, dbsession=dbsession ) group_id = Group._id('_SysAdm_', dbsession) file = File( path='/', group_id = group_id, permanent = True ) dbsession.add( file ) file.type = 'file/folder' file.mimetype = 'application/x-directory' cerr('INFO: root password is %s\n' % root_password)
def login(request): if request.POST: login = request.POST.get('username', '') passwd = request.POST.get('password', '') userclass = UserClass.get( 1 ) userinstance = userclass.auth_user( login, passwd ) if userinstance is None: request.session.flash( ('error', 'ALERT: Wrong username or password.') ) else: request.session['user'] = userinstance request.session.flash( ('info', 'You have been authenticated as: %s' % userinstance.login ) ) return HTTPFound(location='/')
def populate_db( dbsession, initial_groups=None, initial_userclass=None ): if initial_groups: Group.bulk_insert( initial_groups, dbsession=dbsession ) if initial_userclass: UserClass.bulk_insert( initial_userclass, dbsession=dbsession )