【问题标题】:Google App Engine logout urlGoogle App Engine 注销网址
【发布时间】:2010-10-30 14:34:31
【问题描述】:

我无法在 GAE (Python) 中使用注销链接。

这是我正在查看的page

在我的模板中,我创建了一个链接

<p><a href="\users.create_logout_url("/")\">Logout</a></p>

但是当我点击它时,我会收到来自 Chrome 的“链接断开”消息。链接的 url 如下所示:

http://localhost:8085/users.create_logout_url(

我的问题:

谁能解释一下这一般是如何工作的?

开发服务器的正确 url 是什么?

应用服务器的正确 url 是什么?

注销网址中的(“/”)是什么?

谢谢。

编辑

此链接有效;但我不知道为什么:

<p><a href="http://localhost:8085/_ah/login?continue=http%3A//localhost%3A8085/&action=Logout">Logout</a></p>

【问题讨论】:

    标签: google-app-engine logout


    【解决方案1】:

    您使用什么类型的模板?从输出中可以清楚地看出您没有正确转义代码。

    【讨论】:

    • 那么你需要做 ${users.create_logout_url("/")} 来替换那个表达式的结果。
    【解决方案2】:

    在我看来你想这样做:

    self.response.out.write("This is the url: %s", users.create_logout_url("/"))
    

    您也可以使用 GAE 实现的 django 模板将其传递给您的模板。

    from google.appengine.ext.webapp import template
    ...
    ...
    (inside your request handler)
      class Empty: pass
      data = Empty()
      data.logout = users.create_logout_url("/")
      self.response.out.write(template.render(my_tmpl, {'data': data})
    

    一种有用的方法是将各种信息添加到 BaseRequestHandler,然后将其用作所有其他请求处理程序类的基类。

    from google.appengine.ext import webapp
    ...
    class BaseRequestHandler(webapp.RequestHandler):
      def __init__(self):
         webapp.RequestHandler.__init__(self) # extend the base class
         class Empty: pass
         data = Empty()
         data.foo = "bar"
    

    然后您的新类将可以访问您在基类中提供的所有数据。

    class OtherHandler(BaseRequestHandler):
      def get(self):
         self.response.out.write("This is foo: %s" % self.data.foo) # passes str "bar"
    

    希望对你有帮助。

    一个。

    【讨论】:

      【解决方案3】:

      您好,您可以或多或少地关注本文针对用户帐户内容所展示的内容。在 gwt 我存储服务器端的注销/登录 url 并将它们传递给客户端

      http://www.dev-articles.com/article/App-Engine-User-Services-in-JSP-3002

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-11-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-01-18
        • 2011-02-24
        • 2011-02-15
        • 1970-01-01
        相关资源
        最近更新 更多