How do i use repoze.who?

Posted by misterwebz on Stack Overflow See other posts from Stack Overflow or by misterwebz
Published on 2010-06-08T19:38:22Z Indexed on 2010/06/08 19:42 UTC
Read the original article Hit count: 354

Filed under:
|

I'm having some trouble understanding how repoze.who works.

I've followed a tutorial i found by searching on google and here's what i already have:

This is what i added in my middleware.py file

from repoze.who.config import make_middleware_with_config as make_who_with_config

app = make_who_with_config(app, global_conf, app_conf['who.config_file'],
                           app_conf['who.log_file'],
                           app_conf['who.log_level'])

Here's the who.ini : http://pastebin.com/w5Tba2Fp

Here's repoze_auth.py in /lib/auth/:

from paste.httpexceptions import HTTPFound

from iwant.model import User

class UserModelPlugin(object):

def authenticate(self, environ, identity):
    try:
        username = identity['login']
        password = identity['password']
    except KeyError:
        return None

    success = User.authenticate(username, password)

    return success

def add_metadata(self, environ, identity):
    username = identity.get('repoze.who.userid')
    user = User.get(username)

    if user is not None:
        identity['user'] = user

I've also checked the plugins in the repoze.who folder, but i failed to understand how it's supposed to be used.

I'd appreciate it if someone would push me in the right direction.

© Stack Overflow or respective owner

Related posts about python

Related posts about wsgi