Python 如何使用repose.who登录用户?

Python 如何使用repose.who登录用户?,python,pylons,authentication,repoze.who,Python,Pylons,Authentication,Repoze.who,我有一个正在工作的repose.who/what设置(在一个挂架应用程序上)。我现在想在新用户注册后自动登录,而不必使用登录表单。我已经浏览了repose.who文档和源代码,也许我只是错过了它,但如果没有新的post请求通过中间件,我无法找到如何从代码设置登录用户。这可能吗?我整个上午都在处理类似的问题,我发现: 您必须知道,现在有两个版本的repose.who(1和2): 在v1.x中: rememberer = request.environ['repoze.who.plugins']['

我有一个正在工作的repose.who/what设置(在一个挂架应用程序上)。我现在想在新用户注册后自动登录,而不必使用登录表单。我已经浏览了repose.who文档和源代码,也许我只是错过了它,但如果没有新的post请求通过中间件,我无法找到如何从代码设置登录用户。这可能吗?

我整个上午都在处理类似的问题,我发现: 您必须知道,现在有两个版本的repose.who(1和2):

在v1.x中:

rememberer = request.environ['repoze.who.plugins']['cookie']
identity = {'repoze.who.userid': user.username}
response.headerlist = response.headerlist + \
        rememberer.remember(request.environ, identity) 
在v2.x中(因为版本2提供了一个api,所以更简单):

资源: 对于v1: 对于v2:

from repoze.who.api import get_api

who_api = get_api(request.environ)
creds = {}
creds['login'] = yourusername
creds['password'] = yourpassword
authenticated, headers = who_api.login(creds)