什么是google-app-engine </app-directory>中remote_api的'<app-directory>'

时间:2010-05-18 10:00:24

标签: python google-app-engine

http://code.google.com/intl/en/appengine/docs/python/tools/uploadingdata.html

api

从App Engine下载数据

要开始数据下载,请使用适当的参数运行appcfg.py download_data:

appcfg.py download_data --config_file=album_loader.py --filename=album_data_archive.csv --kind=Album <app-directory>

我想从我的应用程序zjm1126.appspot.com下载数据

所以我在commond中写这个:

appcfg.py download_data --config_file=GreetingLoad.py --filename=GreetingLoad.csv  

但是,我不知道如何写'app-directory'

所以,如何写'app-directory'..

感谢

更新

我用这个:

appcfg.py download_data --config_file=helloworld/GreetingLoad.py --filename=a.csv  --kind=Greeting helloworld

,错误是:

D:\zjm_code>appcfg.py download_data --config_file=helloworld/GreetingLoad.py --f
ilename=a.csv  --kind=Greeting helloworld
Application: zjm1126; version: 1-h1.
Downloading data records.
[INFO    ] Logging to bulkloader-log-20100518.195933
[INFO    ] Throttling transfers:
[INFO    ] Bandwidth: 250000 bytes/second
[INFO    ] HTTP connections: 8/second
[INFO    ] Entities inserted/fetched/modified: 20/second
[INFO    ] Batch Size: 10
[INFO    ] Opening database: bulkloader-progress-20100518.195933.sql3
Traceback (most recent call last):
  File "d:\Program Files\Google\google_appengine\appcfg.py", line 68, in <module
>
    run_file(__file__, globals())
  File "d:\Program Files\Google\google_appengine\appcfg.py", line 64, in run_fil
e
    execfile(script_path, globals_)
  File "d:\Program Files\Google\google_appengine\google\appengine\tools\appcfg.p
y", line 2709, in <module>
    main(sys.argv)
  File "d:\Program Files\Google\google_appengine\google\appengine\tools\appcfg.p
y", line 2700, in main
    result = AppCfgApp(argv).Run()
  File "d:\Program Files\Google\google_appengine\google\appengine\tools\appcfg.p
y", line 1763, in Run
    self.action(self)
  File "d:\Program Files\Google\google_appengine\google\appengine\tools\appcfg.p
y", line 2580, in __call__
    return method()
  File "d:\Program Files\Google\google_appengine\google\appengine\tools\appcfg.p
y", line 2446, in PerformDownload
    run_fn(args)
  File "d:\Program Files\Google\google_appengine\google\appengine\tools\appcfg.p
y", line 2368, in RunBulkloader
    sys.exit(bulkloader.Run(arg_dict))
  File "D:\Program Files\Google\google_appengine\google\appengine\tools\bulkload
er.py", line 4012, in Run
    return _PerformBulkload(arg_dict)
  File "D:\Program Files\Google\google_appengine\google\appengine\tools\bulkload
er.py", line 3887, in _PerformBulkload
    exporter = Exporter.RegisteredExporter(kind)
  File "D:\Program Files\Google\google_appengine\google\appengine\tools\bulkload
er.py", line 2901, in RegisteredExporter
    return Exporter.__exporters[kind]
KeyError: 'Greeting'

我的GreetingLoad.py是:

import datetime
from google.appengine.ext import db
from google.appengine.tools import bulkloader


class Greeting(db.Model):
  author = db.UserProperty()
  content = db.StringProperty(multiline=True)
  date = db.DateTimeProperty(auto_now_add=True)



class GreetingLoader(bulkloader.Loader):
    def __init__(self):
        bulkloader.Loader.__init__(self, 'Greeting',
                                   [('author', lambda x: x.decode('utf-8')),
                                    ('content', lambda x: x.decode('utf-8')),
                                    ('date',
                                     lambda x: datetime.datetime.strptime(x, '%m/%d/%Y').date())
                                   ])

loaders = [GreetingLoader]

mu url是:

- url: /remote_api
  script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py
  login: admin

updated2

现在好了,谢谢

appcfg.py download_data --config_file=helloworld/GreetingLoad.py --filename=a.csv  --kind=Greeting helloworld

class AlbumExporter(bulkloader.Exporter):
    def __init__(self):
        bulkloader.Exporter.__init__(self, 'Greeting',
                                     [('author', str, None),
                                      ('content', str, None),
                                      ('date', str, None),
                                     ])

exporters = [AlbumExporter]

1 个答案:

答案 0 :(得分:1)

请看一下这篇文章,它解释了如何设置下载数据:http://code.google.com/appengine/docs/python/tools/uploadingdata.html

app-directory是您在app.yaml文件中设置的路径,以映射到remote_api:

- url: /app-directory
  script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py
  login: admin

回答更新的问题:

将您的loaders = ...行更改为exporters = [GreetingExporter]