def user(request): """ Return a user object """ session = DBSESSION() user = session.query(User).filter_by(id=user_id).first() return dict(title="User", user="******")
def users(request): """ Returns the list of all users """ session = DBSESSION() users = session.query(User).all() return dict(title="UserList", users=users)
def auth(form, value): """ Check the login/password content """ log.debug(u" * Authenticating") db = DBSESSION() login = value.get('login') log.debug(u" + Login {0}".format(login)) password = value.get('password') result = db.query(User).filter_by(login=login).first() log.debug(result) if not result or not result.authenticate(password): log.debug(u" - Authentication Error") message = u"Erreur d'authentification" exc = colander.Invalid(form, message) exc['password'] = message raise exc
def setUpClass(cls): cls.engine = engine_from_config(settings, prefix='sqlalchemy.') cls.DBSession = sessionmaker() cls.connection = cls.engine.connect() DBSESSION.configure(bind=cls.connection)