【问题标题】:nosegae blobstore support?nosgae blobstore 支持?
【发布时间】:2010-12-08 12:56:21
【问题描述】:

我正在尝试找出 nosgae 是否支持 blobstore 进行测试,就像它对数据存储所做的那样。 我在测试 blobstore 上传时遇到了麻烦。有人知道吗?

谢谢。

编辑:

blob 是一个 BlobReferenceProperty()

现在我遇到了一些问题。可能是因为我错过了一些东西。 如果我尝试使用这样的 blob 添加实体:

e = entity(title=title, blob=open('/path/to/image.jpg').read())
e.put()

我得到一个

   File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/datastore_types.py", line 113, in ValidateString
    if len(value.encode('utf-8')) > max_len:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0: ordinal not in range(128)

如果我使用

...
 blob=open('/path/to/image.jpg', 'r')
...

结果是:

File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/blobstore/blobstore.py", line 429, in get_value_for_datastore
    return blob_info.key()
AttributeError: 'file' object has no attribute 'key'

然后,如果我使用 webtest.TestApp 尝试使用像“/_ah/upload/....”这样的上传网址,我会得到 404。我猜是因为我的应用程序不涵盖“/_ah/upload/...” ' 网址。

有什么提示吗?

【问题讨论】:

    标签: python google-app-engine nose blobstore


    【解决方案1】:

    应该这样做 - NoseGAE 只需使用 dev_appserver 的代码来设置相同的环境。

    【讨论】:

    • 现在我遇到了一些问题。可能是因为我错过了一些东西。见上文。
    • @aschmid00 您正在尝试将 BlobReferenceProperty 设置为实际的数据块。这不是它的工作原理 - 您必须将其设置为从 Blobstore API 获得的 BlobKey。
    • 有没有办法用实际的 blob 手动创建这样的 BlobInfo?我很难做到这一点。
    猜你喜欢
    • 2012-07-07
    • 1970-01-01
    • 1970-01-01
    • 2012-10-19
    • 2013-10-03
    • 2012-04-15
    • 2018-04-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多