@view_config(route_name='home', renderer='dashboard.jinja2')
def home_view(request):
if request.authenticated_userid is None:
# most people would probably opt to redirect to the login url
# here instead of rendering a response, but you asked
return render_to_response('login.jinja2', {}, request=request)
# user is logged in, so use the dashboard renderer
return {}
您只需:
然而,pyramid很酷而且有谓词。整洁。因此,我们可以使用
^{pr2}$effective_principals
谓词根据用户是否登录在两个不同的视图之间进行分派:重写SQLAlchemy + URL dispatch wiki tutorial包括一个示例应用程序,该应用程序可以执行您想要的操作,外加密码哈希、授权和测试。这将在金字塔1.7中发布(1.6.1是本文撰写时的当前版本)。您可以从教程的src目录中获取教程中应用程序的完整源代码。在
相关问题 更多 >
编程相关推荐