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
这是Loader Class
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
是的,我试图添加另一个额外的属性'class',它被硬编码到DbSubscrib'(也尝试添加2个属性'DbProduct'和'DbSubscrib',没有任何运气。非常感谢任何帮助。我在goole的网站上找不到一个关于PolyModel和bulkupload的任何细微差别的文档。
答案 0 :(得分:0)
好的,您的问题是无法上传DbSubScrib
,您需要我们DbProduct
。如果您查看存储在数据存储区中的任何DbSubScrib
,它就是DbProduct
类,并且子类在数据存储区中将具有class
属性,用于存储继承类名称
例如
class value: ["DbProduct", "DbSubScrib"]
将您的装载程序类编辑为DbProduct,它将起作用。
答案 1 :(得分: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。