[更新]
我应该注意,这是在一个事务中发生的,并且这个错误是在dev_appserver上生成的。 我没有在生产环境中测试。这似乎不会在生产环境中发生。
[/更新]
我不确定我在这里做错了什么;我的代码几乎与文档示例相同。
我的代码:
filename = files.blobstore.create(mime_type='application/octet-stream')
with files.open(filename, 'a') as f:
f.write(json.dumps(oldblocks, separators=(',', ':')))
files.finalize(filename)
堆栈追踪:
WARNING 2013-01-16 12:37:49,648 tasklets.py:409] suspended generator transaction(context.py:932) raised AttributeError('Entity' object has no attribute '_to_pb')
ERROR 2013-01-16 12:37:49,648 webapp2.py:1552] 'Entity' object has no attribute '_to_pb'
Traceback (most recent call last):
File "/home/rye/local/share/google_appengine/lib/webapp2/webapp2.py", line 1535, in __call__
rv = self.handle_exception(request, response, e)
File "/home/rye/local/share/google_appengine/lib/webapp2/webapp2.py", line 1529, in __call__
rv = self.router.dispatch(request, response)
File "/home/rye/local/share/google_appengine/lib/webapp2/webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
File "/home/rye/local/share/google_appengine/lib/webapp2/webapp2.py", line 1102, in __call__
return handler.dispatch()
File "/home/rye/local/share/google_appengine/lib/webapp2/webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)
File "/home/rye/local/share/google_appengine/lib/webapp2/webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
File "/home/rye/Dropbox/projects/web/voxwright/voxwright.py", line 202, in put
result = saveProject(data['id'], data['blocks'])
File "/home/rye/local/share/google_appengine/google/appengine/ext/ndb/model.py", line 3583, in inner_transactional_wrapper
return transaction(f, **ctx_options)
File "/home/rye/local/share/google_appengine/google/appengine/ext/ndb/utils.py", line 136, in positional_wrapper
return wrapped(*args, **kwds)
File "/home/rye/local/share/google_appengine/google/appengine/ext/ndb/model.py", line 3526, in transaction
return fut.get_result()
File "/home/rye/local/share/google_appengine/google/appengine/ext/ndb/tasklets.py", line 325, in get_result
self.check_success()
File "/home/rye/local/share/google_appengine/google/appengine/ext/ndb/tasklets.py", line 371, in _help_tasklet_along
value = gen.send(val)
File "/home/rye/local/share/google_appengine/google/appengine/ext/ndb/context.py", line 923, in transaction
result = callback()
File "/home/rye/local/share/google_appengine/google/appengine/ext/ndb/model.py", line 3582, in <lambda>
f = lambda: func(*args, **kwds)
File "/home/rye/Dropbox/projects/web/voxwright/voxwright.py", line 102, in saveProject
files.finalize(filename)
File "/home/rye/local/share/google_appengine/google/appengine/api/files/file.py", line 568, in finalize
f.close(finalize=True)
File "/home/rye/local/share/google_appengine/google/appengine/api/files/file.py", line 291, in close
self._make_rpc_call_with_retry('Close', request, response)
File "/home/rye/local/share/google_appengine/google/appengine/api/files/file.py", line 427, in _make_rpc_call_with_retry
_make_call(method, request, response)
File "/home/rye/local/share/google_appengine/google/appengine/api/files/file.py", line 250, in _make_call
rpc.check_success()
File "/home/rye/local/share/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 570, in check_success
self.__rpc.CheckSuccess()
File "/home/rye/local/share/google_appengine/google/appengine/api/apiproxy_rpc.py", line 156, in _WaitImpl
self.request, self.response)
File "/home/rye/local/share/google_appengine/google/appengine/api/apiproxy_stub.py", line 125, in MakeSyncCall
method(request, response)
File "/home/rye/local/share/google_appengine/google/appengine/api/files/file_service_stub.py", line 652, in _Dynamic_Close
self.open_files[filename].finalize()
File "/home/rye/local/share/google_appengine/google/appengine/api/files/file_service_stub.py", line 596, in finalize
datastore.Put(blob_info)
File "/home/rye/local/share/google_appengine/google/appengine/api/datastore.py", line 579, in Put
return PutAsync(entities, **kwargs).get_result()
File "/home/rye/local/share/google_appengine/google/appengine/api/datastore.py", line 556, in PutAsync
return _GetConnection().async_put(config, entities, local_extra_hook)
File "/home/rye/local/share/google_appengine/google/appengine/datastore/datastore_rpc.py", line 1542, in async_put
pbs = [self.__adapter.entity_to_pb(entity) for entity in entities]
File "/home/rye/local/share/google_appengine/google/appengine/ext/ndb/model.py", line 562, in entity_to_pb
pb = ent._to_pb()
AttributeError: 'Entity' object has no attribute '_to_pb'
答案 0 :(得分:1)
这看起来像我提出的同一个错误:http://code.google.com/p/googleappengine/issues/detail?id=8354
主演并且可能评论说不仅仅是get_serving_url
会触发它,它会让Google知道这很重要! (目前,我已经检查了is_sdk在我的blob处理,事务包装代码周围散落,这很可怕。)