Exemple #1
0
def register(request):
    db = DBSession()
    form = Form(request, RegistrationSchema)
    if form.validate():
        user = form.bind(User(), exclude=['password_confirmation'])
        group = db.query(Group).filter(Group.name == 'users').one()
        user.groups.append(group)
        db.add(user)
        db.flush()
        transaction.commit()
        return HTTPFound(location=request.route_url('root'))
    return dict(form=FormRenderer(form))
Exemple #2
0
def add(request):
    user_id = authenticated_userid(request)
    form = Form(request, AddGameSchema, state=State(user_id=user_id),
                defaults=dict(port=23))
    if form.validate():
        game = form.bind(Game())
        game.user_id = user_id
        db = DBSession()
        db.add(game)
        db.flush()
        transaction.commit()
        
        #template_dir = os.path.join(os.path.dirname(__file__),
        #                            '_game_session_template')
        #session_dir = os.path.join(self.users_dir, metauser.name, session.name)
        #if not os.path.exists(session_dir):
        #    shutil.copytree(template_dir, session_dir)
        
        return HTTPFound(location=request.route_url('games'))
    return dict(form=FormRenderer(form))