Re: [Repoze-dev] login by apy of repoze 1
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 ___ Repoze-dev mailing list Repoze-dev@lists.repoze.org http://lists.repoze.org/listinfo/repoze-dev
Re: [Repoze-dev] login by apy of repoze 1
-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 tsea...@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- ___ Repoze-dev mailing list Repoze-dev@lists.repoze.org http://lists.repoze.org/listinfo/repoze-dev