【发布时间】:2010-11-16 17:50:50
【问题描述】:
我有一个个人资料类:
class profile(db.Model):
user = db.stringProperty()
# Other properties ...
access = db.ListProperty(db.keys)
class apps(db.Model):
name = db.StringProperty()
配置文件类已经存在一段时间了,但我们最近添加了访问字段,该字段将存储应用程序的密钥。 现在我们在应用程序上添加配置文件权限,访问字段不会在模型中更新。
这在本地主机上完全可以正常工作,但是当我在服务器上更新它时出现此错误 “'NoneType' 对象没有属性 'access'” 有没有人遇到过同样的情况
更新: 发现配置文件类中的一个对象被返回为 None。这是在 localhost 上获取配置文件对象但在服务器上没有获取配置文件对象的代码
liuser = users.User(request.POST['user'])
#request.POST['user'] gets user Gmail ID, which is being converted to user object
profiles=Profile.all().filter(" user =", liuser).get()
userprofile=profiles
#tried below code which returns "'NoneType' object has no attribute 'access'" on server, the same gets a profile object on localhost
if not hasattr(userprofile, "access"):
userprofile.access=[]
@Robert 希望现在格式没问题。
谢谢你 西克里希纳
【问题讨论】:
-
如果您的代码被格式化,则更容易阅读和回答您的问题。
-
能否包含用于读取和更新配置文件实体的代码。您可能还想包含您正在使用的实际代码。您的代码有几个问题,例如“db.keys”和“db.stringProperty”。
标签: google-app-engine google-cloud-datastore maven-gae-plugin