我正在尝试使用此程序包为我执行__name__和__parent__注册。
按照github上的说明进行操作:
from pyramid.interfaces import ITraverser
from zope.interface import Interface
from pyramid_traversalwrapper import ModelGraphTraverser
config.registry.registerAdapter(ModelGraphTraverser, (Interface,),
ITraverser)
但得到了这个错误:
Traceback (most recent call last):
File "/home/rotem/Programming/Workspace/pyramid/env/local/lib/python2.7/site-packages/waitress-0.8.9-py2.7.egg/waitress/channel.py", line 337, in service
task.service()
File "/home/rotem/Programming/Workspace/pyramid/env/local/lib/python2.7/site-packages/waitress-0.8.9-py2.7.egg/waitress/task.py", line 173, in service
self.execute()
File "/home/rotem/Programming/Workspace/pyramid/env/local/lib/python2.7/site-packages/waitress-0.8.9-py2.7.egg/waitress/task.py", line 392, in execute
app_iter = self.channel.server.application(env, start_response)
File "/home/rotem/Programming/Workspace/pyramid/env/local/lib/python2.7/site-packages/pyramid/router.py", line 242, in __call__
response = self.invoke_subrequest(request, use_tweens=True)
File "/home/rotem/Programming/Workspace/pyramid/env/local/lib/python2.7/site-packages/pyramid/router.py", line 217, in invoke_subrequest
response = handle_request(request)
File "/home/rotem/Programming/Workspace/pyramid/env/local/lib/python2.7/site-packages/pyramid/tweens.py", line 21, in excview_tween
response = handler(request)
File "/home/rotem/Programming/Workspace/pyramid/env/local/lib/python2.7/site-packages/pyramid_tm-0.11-py2.7.egg/pyramid_tm/__init__.py", line 94, in tm_tween
reraise(*exc_info)
File "/home/rotem/Programming/Workspace/pyramid/env/local/lib/python2.7/site-packages/pyramid_tm-0.11-py2.7.egg/pyramid_tm/__init__.py", line 75, in tm_tween
response = handler(request)
File "/home/rotem/Programming/Workspace/pyramid/env/local/lib/python2.7/site-packages/pyramid/router.py", line 125, in handle_request
tdict = traverser(request)
File "/home/rotem/Programming/Workspace/pyramid/env/local/lib/python2.7/site-packages/pyramid_traversalwrapper-0.1-py2.7.egg/pyramid_traversalwrapper/__init__.py", line 36, in __call__
if 'bfg.routes.matchdict' in environ:
TypeError: argument of type 'Request' is not iterable
我在github中查看了pyramid_traversalwrapper,最后一次提交是在4年前。
还看了金字塔1.4中的变化:
不再可能直接将环境词典传递给 pyramid.traversal.ResourceTreeTraverser .__ call __(又名 ModelGraphTraverser .__ call__)。相反,您必须传递请求 宾语。传递环境而不是请求已经生成了一个 自金字塔1.1以来的弃用警告。
这个包裹死了吗?如果是的话,还有其他选择吗?