我很难理解如何做一些愚蠢的事情。我有一个像这样的 GAE 模型:
class Post(Base):
img1 = blobstore.BlobReferenceProperty(blobstore.BlobKey, required=False)
这是我用于保存 blob 密钥的方法:
post.img1 = blobstore.BlobInfo.get(blob_key).key()
但是当我尝试从 db 恢复 blobstore 密钥时
post = model.Post.getThePostInSomeWay()
blob_key = post.img1
抛出以下错误:
文件“/Users/piero/Sviluppo/dataplanner/main.py”,第 240 行,在 display_post_by_id 中
blob_key = post.img1
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/db/__init__.py", line 604, in __get__
return getattr(model_instance, self._attr_name())
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/db/__init__.py", line 756, in _attr_name
return '_' + self.name
TypeError: cannot concatenate 'str' and 'NoneType' objects
请注意,如果我记录整个帖子对象,我会看到 img1 字段
INFO 2012-07-30 06:54:43,490 main.py:239] Post(key=Key('Post', 31), allow_comments=True, body=u'<p>Test</p>', created_utc=None, img1=datastore_types.BlobKey('YPeUXQSfL_VqwKZITPtk-w=='), title=Test')
问题是什么?谢谢