0

为 db.polymodel.PolyModel 类型的实体批量上传失败并出现以下错误(我已设法上传其他实体并且所有导入都应该存在):

[INFO    ] Logging to bulkloader-log-20130901.191015
[INFO    ] Throttling transfers:
[INFO    ] Bandwidth: 250000 bytes/second
[INFO    ] HTTP connections: 8/second
[INFO    ] Entities inserted/fetched/modified: 20/second
[INFO    ] Batch Size: 10
Traceback (most recent call last):
  File "c:/program files (x86)/google/google_appengine/appcfg.py", line 171, in
<module>
    run_file(__file__, globals())
  File "c:/program files (x86)/google/google_appengine/appcfg.py", line 167, in
run_file
    execfile(script_path, globals_)
  File "c:\program files (x86)\google\google_appengine\google\appengine\tools\ap
pcfg.py", line 4252, in <module>
    main(sys.argv)
  File "c:\program files (x86)\google\google_appengine\google\appengine\tools\ap
pcfg.py", line 4243, in main
    result = AppCfgApp(argv).Run()
  File "c:\program files (x86)\google\google_appengine\google\appengine\tools\ap
pcfg.py", line 2402, in Run
    self.action(self)
  File "c:\program files (x86)\google\google_appengine\google\appengine\tools\ap
pcfg.py", line 3979, in __call__
    return method()
  File "c:\program files (x86)\google\google_appengine\google\appengine\tools\ap
pcfg.py", line 3791, in PerformUpload
    run_fn(args)
  File "c:\program files (x86)\google\google_appengine\google\appengine\tools\ap
pcfg.py", line 3682, in RunBulkloader
    sys.exit(bulkloader.Run(arg_dict))
  File "c:\program files (x86)\google\google_appengine\google\appengine\tools\bu
lkloader.py", line 4395, in Run
    return _PerformBulkload(arg_dict)
  File "c:\program files (x86)\google\google_appengine\google\appengine\tools\bu
lkloader.py", line 4206, in _PerformBulkload
    LoadConfig(config_file)
  File "c:\program files (x86)\google\google_appengine\google\appengine\tools\bu
lkloader.py", line 3873, in LoadConfig
    Loader.RegisterLoader(cls())
  File "SubscribLoader.py", line 23, in __init__
    ('description', lambda x: x.decode('utf-8')),
  File "c:\program files (x86)\google\google_appengine\google\appengine\tools\bu
lkloader.py", line 2674, in __init__
    GetImplementationClass(kind)
  File "c:\program files (x86)\google\google_appengine\google\appengine\tools\bu
lkloader.py", line 968, in GetImplementationClass
    implementation_class = db.class_for_kind(kind_or_class_key)
  File "c:\program files (x86)\google\google_appengine\google\appengine\ext\db\_
_init__.py", line 296, in class_for_kind
    raise KindError('No implementation for kind \'%s\'' % kind)
google.appengine.ext.db.KindError: No implementation for kind 'DbSubscrib

' 这是命令行:

appcfg.py upload_data --config_file=SubscribLoader.py --filename=Subscrib.csv --
kind=(DbProduct,DbSubscrib) --url=https://.../_ah/remote_api -A appname

这是加载器类

import datetime
from google.appengine.tools import bulkloader
from Db.shop.DbSubscrib import DbSubscrib


class SubscribLoader (bulkloader.Loader):
    def __init__(self):
        bulkloader.Loader.__init__(self, ('DbProduct','DbSubscrib'),
                                   [
                                    ('name', lambda x: x.decode('utf-8')),
                                    ('createDate',
                                     lambda x: datetime.datetime.strptime(x, '%m/%d/%Y').date()),
                                    ('level', lambda x: x.decode('utf-8')),
                                    ('duration', lambda x: x.decode('utf-8')),
                                    ('service', lambda x: x.decode('utf-8')),
                                    ('description', lambda x: x.decode('utf-8')),
                                   ])

loaders = [SubscribLoader]

DbSubcrib 派生自 DbProduct,它从 polymodel.PolyModel 驱动

顺便说一句,我尝试添加另一个硬编码到 DbSubscrib 的额外属性“类”(还尝试添加 2 个属性“DbProduct”和“DbSubscrib”,但没有任何运气。

任何帮助深表感谢。我在 goole 的网站上找不到涉及 PolyModel 和批量上传的任何细微差别的文档。

4

2 回答 2

0

好的,你的问题是你不能上传DbSubScrib,你需要我们DbProduct。如果您查看任何DbSubScrib存储在 Datastore 中的类,则它是一个DbProduct类,并且子类将class在存储继承类名称的数据存储中具有一个属性

例如

 class  value: ["DbProduct", "DbSubScrib"]

将您的加载器类更改为 DbProduct ,它将起作用。

于 2013-09-02T23:34:20.517 回答
0

经过一番修补后,在 google appengine 的 bulkuploader 中发现了问题:似乎有人尝试让 PolyModel 的 bulkupload 工作,但不确定为什么这部分没有修复(或测试)。也许我遗漏了一些东西 - 无论如何,这些更改对我有用......修复在 google.appengine.tools.bulkloader.py 的以下行中:

class BulkTransporterApp(object):
  """Class to wrap bulk transport application functionality."""

  def __init__(self,

....
....


line 3399 - old -     self.kind = arg_dict['kind']

line 3399 - new -    self.kind = ParseKind (arg_dict['kind'])

进行此更改后,我可以上传。

我已经修复了上面的 Bulkuploader 模块和命令行,以了解如何上传 PolyModel。

于 2013-09-08T19:33:42.353 回答