2011-10-30 37 views
10

我正在将我的gae应用程序迁移到python 2.7。这是我的新的app.yaml:如何将我的app.yaml迁移到2.7?

application: webfaze 
version: main 
runtime: python27 
api_version: 1 
threadsafe: true 

handlers: 
- url: /mapreduce(/.*)? 
    script: mapreduce/main.application 

- url: /(.*\.(html|css|js|gif|jpg|png|ico|swf)) 
    static_files: static/\1 
    upload: static/.* 
    expiration: "1d" 

- url: .* 
    script: main.application 

- url: /task/.* 
    script: main.application 
    login: admin 

但我收到此错误信息:

Error parsing yaml file: 
Invalid object: 
threadsafe cannot be enabled with CGI handler: mapreduce/main.application 
    in "webfaze/app.yaml", line 22, column 1 

你能告诉我如何解决这个错误吗?

回答

7

检查source code,它看起来你需要定义你的处理程序的路径没有任何斜线:

if (handler.script and (handler.script.endswith('.py') or 
     '/' in handler.script)): 
     raise appinfo_errors.ThreadsafeWithCgiHandler(
        'threadsafe cannot be enabled with CGI handler: %s' % 
        handler.script) 

移动application.py到项目的根目录,并相应修改处理程序的路径。

+0

谢谢你是真的,我可以忽略mapreduce部分,因为我目前没有使用它。现在更新通过了语法检查,我很好奇看到现在发生了什么,我刚刚运行'set_default_version' –

+7

或将其命名为'mapreduce.main.application'。 –

+0

谢谢@尼克约翰逊提供完整的解决方案。我可以很轻松地将整个应用程序迁移到python 2.7 :-) –

7

变化:

- url: /mapreduce(/.*)? 
    script: mapreduce/main.application 

要:

- url: /mapreduce(/.*)? 
    script: mapreduce.main.application 

您可能还需要一个__init__.py添加到 'MapReduce的' 文件夹,如果不存在已经有了。这将使python将该文件夹解释为模块。

+0

我试过最新版本,它似乎从应用程序更改为APP – wonglik

+0

@wonglik按'最新版本'哪个版本会是。我正在运行SDK的v.1.7.0,将“应用程序”更改为“应用程序”会引发500(服务器)错误。 –

+0

对不起。我的意思是MapReduce Bundle的最新版本 - 1.6.2取自https://developers.google.com/appengine/downloads – wonglik