通过批量导出程序/批量上传程序下载应用程序引擎ndb实体

时间:2012-11-26 19:11:53

标签: google-app-engine app-engine-ndb

上下文:

我的模型类继承自基类:

class BaseModel(ndb.model):
  # commom fields and methods

class SpecificModel(BaseModel):
  # specific fields and methods

问题:

我想使用appengine bulkuploader service导出SpecificModel实体。

我已经定义了配置文件(data_loader.py):

import sys
sys.path.append('.') ## this is to ensure that it finds the file 'models.py'
from google.appengine.ext import ndb
from google.appengine.tools import bulkloader
from models import *

class SpecificModelExporter(bulkloader.Exporter):
  def __init__(self):
    bulkloader.Exporter.__init__(self, 'SpecificModel',
                                 [('fieldOne', str, None),
                                  ('fieldTwo', str, None)
                                 ])

    exporters = [ SpecificModelExporter ]

我使用以下命令下载数据:

  appcfg.py download_data --config_file=data_loader.py --filename=data.csv --kind=SpecificModel --url=http://url.appspot.com/_ah/remote_api

当我尝试下载数据时,我收到以下错误

google.appengine.ext.db.KindError: No implementation for kind 'SpecificModel'

任何线索?

1 个答案:

答案 0 :(得分:2)

查看source code

您的模型将在GetImplementationClass通过

查找
implementation_class = db.class_for_kind(kind_or_class_key)

db模型的注册表不会包含您定义的任何ndb模型。在ndb.Model._kind_map中创建了类似的注册表,并且在那里找不到您定义的任何db模型。

注意:到目前为止as I can tell,在批量加载程序或等效的ndb批量加载程序中没有相应的问题/功能请求要求ndb支持。可能值得归档并主演它。