0

不幸的是,我错误地将我的 blob 密钥存储在数据存储中,因此需要自己迁移它们。

我正在使用主从到 HRD 迁移文档:

https://developers.google.com/appengine/docs/adminconsole/migration

最后,他们提到以下内容以获取新密钥:

from google.appengine.ext import blobstore

def GetNewBlobKey(old_key)
  return blobstore.BlobMigrationRecord.get_new_blob_key(old_key)

我完全按照上面的方式做,但得到以下错误:

'module' object has no attribute 'BlobMigrationRecord'
Traceback (most recent call last):
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1511, in __call__
    rv = self.handle_exception(request, response, e)
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1505, in __call__
    rv = self.router.dispatch(request, response)
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1253, in default_dispatcher
    return route.handler_adapter(request, response)
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1077, in __call__
    return handler.dispatch()
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 547, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 545, in dispatch
    return method(*args, **kwargs)
  File "/base/data/home/apps/1.359990895908922231/main.py", line 1302, in post
    userEntity.imageUrlBlobKey = blobstore.BlobMigrationRecord.get_new_blob_key(userEntity.imageUrlBlobKey)
AttributeError: 'module' object has no attribute 'BlobMigrationRecord'

任何帮助将非常感激

4

1 回答 1

0

它被错误地排除在 1.7.0 版本之外。它将在 1.7.1 版本中,在此之前您可以在您的应用程序中使用此代码:

class BlobMigrationRecord(db.Model):
  """A model that records the result of a blob migration."""

  new_blob_key = BlobReferenceProperty(indexed=False)

  @classmethod
  def kind(cls):
    return blobstore.BLOB_MIGRATION_KIND

  @classmethod
  def get_by_blob_key(cls, old_blob_key):
    """Fetches the BlobMigrationRecord for the given blob key.

    Args:
      old_blob_key: The blob key used in the previous app.

    Returns:
      A instance of blobstore.BlobMigrationRecord or None
    """
    return cls.get_by_key_name(str(old_blob_key))

  @classmethod
  def get_new_blob_key(cls, old_blob_key):
    """Looks up the new key for a blob.

    Args:
      old_blob_key: The original blob key.

    Returns:
      The blobstore.BlobKey of the migrated blob.
    """
    record = cls.get_by_blob_key(old_blob_key)
    if record:
      return record.new_blob_key.key()

请注意,这与 1.7.1 版本中包含的内容略有不同。具体来说,“new_blob_key”属性将被命名为“new_blob_ref”(1.7.1 还修复了覆盖 BlobReferenceProperty 的属性名称的错误)。

于 2012-07-09T17:18:46.363 回答