[Repoze-dev] login by apy of repoze 1

6 views
Skip to first unread message

alex bodnaru

unread,
Mar 11, 2012, 5:36:04 PM3/11/12
to repoz...@lists.repoze.org

hello friends,

thanks again for repoze.*

one question: i've seen an api login method for repoze 2.

from repoze.who.api import get_api
who_api = get_api(request.environ)
authenticated, headers = \
who_api.login(dict(login=Login, password=UserPass))

how could i login a user in a program using repoze 1?

i came up with the following solution, but is it the best way to go?

plugins = request.environ.get('repoze.who.plugins').values()
rememberers = [auth for auth in plugins if hasattr(auth, 'remember')]

res = rememberers and \
rememberers[0].remember(request.environ, dict(login=Login, password=UserPass))


best regards,
alex
_______________________________________________
Repoze-dev mailing list
Repoz...@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev

Tres Seaver

unread,
Mar 11, 2012, 5:47:28 PM3/11/12
to alexbod...@gmail.com, repoz...@lists.repoze.org
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 03/11/2012 05:36 PM, alex bodnaru wrote:
>
> hello friends,
>
> thanks again for repoze.*

Glad you find them useful!

> one question: i've seen an api login method for repoze 2.
>
> from repoze.who.api import get_api who_api = get_api(request.environ)
> authenticated, headers = \ who_api.login(dict(login=Login,
> password=UserPass))
>
> how could i login a user in a program using repoze 1?

You have put your finger on it: The separate API is really the major new
feature in r.who 2.0.

> i came up with the following solution, but is it the best way to go?
>
> plugins = request.environ.get('repoze.who.plugins').values()
> rememberers = [auth for auth in plugins if hasattr(auth, 'remember')]
>
> res = rememberers and \ rememberers[0].remember(request.environ,
> dict(login=Login, password=UserPass))

That is pretty much the required workaround for the lack of an API in
r.who 1.x.


Tres.
- --
===================================================================
Tres Seaver +1 540-429-0999 tse...@palladion.com
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk9dHXAACgkQ+gerLs4ltQ6qNACfcIuAfVIQQpc5+d/1LnFg6F/I
DrUAoLX4+JQ2hSx40ZoeWEGh1xBv4kW4
=AUsh
-----END PGP SIGNATURE-----

alex bodnaru

unread,
Mar 13, 2012, 8:22:06 AM3/13/12
to repoz...@lists.repoze.org
On 03/11/2012 11:47 PM, Tres Seaver wrote:
> On 03/11/2012 05:36 PM, alex bodnaru wrote:
>
>> hello friends,
>
>> thanks again for repoze.*
>
> Glad you find them useful!
>
>> one question: i've seen an api login method for repoze 2.
>
>> from repoze.who.api import get_api who_api = get_api(request.environ)
>> authenticated, headers = \ who_api.login(dict(login=Login,
>> password=UserPass))
>
>> how could i login a user in a program using repoze 1?
>
> You have put your finger on it: The separate API is really the major new
> feature in r.who 2.0.
>
>> i came up with the following solution, but is it the best way to go?
>
>> plugins = request.environ.get('repoze.who.plugins').values()
>> rememberers = [auth for auth in plugins if hasattr(auth, 'remember')]
>
>> res = rememberers and \ rememberers[0].remember(request.environ,
>> dict(login=Login, password=UserPass))
>
> That is pretty much the required workaround for the lack of an API in
> r.who 1.x.
>
>
> Tres.

thank you very much.

best regards,
alex

Reply all
Reply to author
Forward
0 new messages