0

残念ながら、ブロブ キーをデータストアに保存するというミスを犯したため、自分で移行する必要があります。

マスター/スレーブから 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 に答える