App引擎如果ELIF其他工作在开发但不生产 [英] App Engine if elif else working on dev but not production

查看:99
本文介绍了App引擎如果ELIF其他工作在开发但不生产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行下面的代码时,如果users.is_current_user_admin()运行以下代码,那么

  user = users.get_current_user() :
loggedin ='Admin'
elif user:
loggedin ='User'
else:
loggedin ='Anonymous'
解决方案

这个问题与if / elif / else或users.create_login_url()无关。问题在于,当用户使用users.create_login_url()以HTTPS登录时,App Engine无法识别http请求上的登录用户。我在这个此处。我相信这与Cookie的设置有关。



代码开发Dev而不是开发的原因在于开发环境如何处理HTTPS将其重新映射到http并提供避免该问题的请求。


When I run the following code

user = users.get_current_user()
if users.is_current_user_admin():
    loggedin = 'Admin'
elif user:
    loggedin = 'User'
else:
    loggedin = 'Anonymous'

on the development environment I get Admin when logged in as an Administrator, User as a User, and Anonymous when not logged in. When on production I always get Anonymous. Why is this not working?

解决方案

The problem has nothing to do with if/elif/else or users.create_login_url(). The issue is with App Engine not recognizing a logged in user on a http request when the user logged in with HTTPS with users.create_login_url(). I've created a new question on this here. I believe it has something to do with how the cookie is being set.

The reason the code was working on Dev and not production is how the development environment handles HTTPS urls it remaps it to http and serves the request avoiding the problem.

这篇关于App引擎如果ELIF其他工作在开发但不生产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆