我的 Pyramid 应用程序在粘贴 httpserver 中运行时运行良好,但在 google 应用程序引擎中引发异常。
/hello/{name} url 在粘贴服务器和应用引擎中都可以正常工作
/test url 在粘贴服务器中工作正常,但在应用程序引擎中我得到了下面的 Traceback。
有任何想法吗?
from pyramid.config import Configurator
from pyramid.response import Response
def hello_world(request):
return Response('Hello %(name)s!' % request.matchdict)
def test(request):
return dict()
settings = {'mako.directories':'mako_templates'}
config = Configurator(settings=settings)
config.add_route('hello', '/hello/{name}')
config.add_route('test', '/test', view=test, renderer='test.mako')
config.add_view(hello_world, route_name='hello')
wsgi_app = config.make_wsgi_app()
来自谷歌应用引擎的追溯:
ERROR 2013-01-17 02:48:08,893 wsgi.py:235]
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 223, in Handle
result = handler(dict(self._environ), self._StartResponse)
File "/Users/mnaber/Documents/workspace/UnifiedClassified/site-packages/pyramid/router.py", line 251, in __call__
response = self.invoke_subrequest(request, use_tweens=True)
File "/Users/mnaber/Documents/workspace/UnifiedClassified/site-packages/pyramid/router.py", line 227, in invoke_subrequest
response = handle_request(request)
File "/Users/mnaber/Documents/workspace/UnifiedClassified/site-packages/pyramid/tweens.py", line 21, in excview_tween
response = handler(request)
File "/Users/mnaber/Documents/workspace/UnifiedClassified/site-packages/pyramid/router.py", line 161, in handle_request
response = view_callable(context, request)
File "/Users/mnaber/Documents/workspace/UnifiedClassified/site-packages/pyramid/config/views.py", line 367, in rendered_view
context)
File "/Users/mnaber/Documents/workspace/UnifiedClassified/site-packages/pyramid/renderers.py", line 531, in render_view
return self.render_to_response(response, system, request=request)
File "/Users/mnaber/Documents/workspace/UnifiedClassified/site-packages/pyramid/renderers.py", line 561, in render_to_response
result = self.render(value, system_values, request=request)
File "/Users/mnaber/Documents/workspace/UnifiedClassified/site-packages/pyramid/renderers.py", line 534, in render
renderer = self.renderer
File "/Users/mnaber/Documents/workspace/UnifiedClassified/site-packages/pyramid/decorator.py", line 39, in __get__
val = self.wrapped(inst)
File "/Users/mnaber/Documents/workspace/UnifiedClassified/site-packages/pyramid/renderers.py", line 518, in renderer
return factory(self)
File "/Users/mnaber/Documents/workspace/UnifiedClassified/site-packages/pyramid/mako_templating.py", line 129, in __call__
directories = [ abspath_from_asset_spec(d) for d in directories ]
File "/Users/mnaber/Documents/workspace/UnifiedClassified/site-packages/pyramid/asset.py", line 43, in abspath_from_asset_spec
return pkg_resources.resource_filename(pname, filename)
File "/Users/mnaber/Documents/workspace/UnifiedClassified/site-packages/pkg_resources.py", line 840, in resource_filename
return get_provider(package_or_requirement).get_resource_filename(
File "/Users/mnaber/Documents/workspace/UnifiedClassified/site-packages/pkg_resources.py", line 160, in get_provider
__import__(moduleOrReq)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 692, in Decorate
return func(self, *args, **kwargs)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1766, in load_module
return self.FindAndLoadModule(submodule, fullname, search_path)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 692, in Decorate
return func(self, *args, **kwargs)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1630, in FindAndLoadModule
description)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 692, in Decorate
return func(self, *args, **kwargs)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1577, in LoadModuleRestricted
description)
ImportError: Cannot re-init internal module __main__
INFO 2013-01-17 02:48:08,909 dev_appserver.py:3103] "GET /test HTTP/1.1" 500 -