开发者

Pyramid 1.2 on Google App Engine causes import error

开发者 https://www.devze.com 2023-04-09 11:57 出处:网络
I\'m trying to run Pyramid on GAE by following the steps outlined here. Everything works fine on dev server, but when deployed to Google\'s servers, the following error occurs:

I'm trying to run Pyramid on GAE by following the steps outlined here. Everything works fine on dev server, but when deployed to Google's servers, the following error occurs:

<type 'exceptions.ImportError'>: cannot import name BaseRequest
Traceback (most recent call last):
  File "/base/data/home/apps/.../0-0-1.353634463095353211/main.py", line 9, in <mo开发者_StackOverflowdule>
    from pyramid.config import Configurator
  File "/base/data/home/apps/.../0-0-1.353634463095353211/lib/dist/pyramid/__init__.py", line 1, in <module>
    from pyramid.request import Request
  File "/base/data/home/apps/.../0-0-1.353634463095353211/lib/dist/pyramid/request.py", line 6, in <module>
    from webob import BaseRequest

This is probably caused by the fact that GAE uses WebOb 0.9 while Pyramid uses WebOb 1.1 (it resides under lib/dist/webob in my project), since BaseRequest is missing in 0.9.

In the main.py file there is this fragment:

sys.path.insert(0,'lib/dist')

but it seems to help only for dev server case. I there a way to force GAE runtime to use version 1.1 included in my application?


It's not really a solution, per-se, but we're about to release the new Python runtime, Python 2.7, which includes updated versions of libraries, including webob 1.1. Perhaps you could target your app against that, instead of against the 2.5 runtime?


Apart from the runtime update, I found another workaround. I've renamed the WebOb 1.1 module from webob to webobx and made pyramid reference the renamed webobx module. Not very elegant and will have to be repeated if I get to upgrade pyramid, but works.

0

精彩评论

暂无评论...
验证码 换一张
取 消