3
我使用金字塔1.4a1和我有這個用戶謂:金字塔用戶謂詞不工作
我添加它,像這樣:
config.add_subscriber_predicate('route_name', RouteName)
但是,每當我嘗試使用它,像這樣:
@subscriber(ContextFound, route_name='user.register')
def check_invitation(event):
# Check invitation token before running registration view code ...
我得到這個回溯:
Traceback (most recent call last):
File "/Workspace/Personal/project/.env/bin/pserve", line 8, in <module>
load_entry_point('pyramid==1.4a1', 'console_scripts', 'pserve')()
File "/Workspace/Personal/project/.env/local/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 47, in main
return command.run()
File "/Workspace/Personal/project/.env/local/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 290, in run
relative_to=base, global_conf=vars)
File "/Workspace/Personal/project/.env/local/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 318, in loadapp
return loadapp(app_spec, name=name, relative_to=relative_to, **kw)
File "/Workspace/Personal/project/.env/local/lib/python2.7/site-packages/PasteDeploy-1.5.0-py2.7.egg/paste/deploy/loadwsgi.py", line 247, in loadapp
return loadobj(APP, uri, name=name, **kw)
File "/Workspace/Personal/project/.env/local/lib/python2.7/site-packages/PasteDeploy-1.5.0-py2.7.egg/paste/deploy/loadwsgi.py", line 272, in loadobj
return context.create()
File "/Workspace/Personal/project/.env/local/lib/python2.7/site-packages/PasteDeploy-1.5.0-py2.7.egg/paste/deploy/loadwsgi.py", line 710, in create
return self.object_type.invoke(self)
File "/Workspace/Personal/project/.env/local/lib/python2.7/site-packages/PasteDeploy-1.5.0-py2.7.egg/paste/deploy/loadwsgi.py", line 146, in invoke
return fix_call(context.object, context.global_conf, **context.local_conf)
File "/Workspace/Personal/project/.env/local/lib/python2.7/site-packages/PasteDeploy-1.5.0-py2.7.egg/paste/deploy/util.py", line 56, in fix_call
val = callable(*args, **kw)
File "/Workspace/Personal/project/project/__init__.py", line 49, in main
return config.make_wsgi_app()
File "/Workspace/Personal/project/.env/local/lib/python2.7/site-packages/pyramid/config/__init__.py", line 955, in make_wsgi_app
self.commit()
File "/Workspace/Personal/project/.env/local/lib/python2.7/site-packages/pyramid/config/__init__.py", line 629, in commit
self.action_state.execute_actions(introspector=self.introspector)
File "/Workspace/Personal/project/.env/local/lib/python2.7/site-packages/pyramid/config/__init__.py", line 1083, in execute_actions
tb)
File "/Workspace/Personal/project/.env/local/lib/python2.7/site-packages/pyramid/config/__init__.py", line 1075, in execute_actions
callable(*args, **kw)
File "/Workspace/Personal/project/.env/local/lib/python2.7/site-packages/pyramid/config/adapters.py", line 53, in register
order, preds, phash = predlist.make(self, **predicates)
File "/Workspace/Personal/project/.env/local/lib/python2.7/site-packages/pyramid/config/util.py", line 264, in make
pred = predicate_factory(val, config)
pyramid.exceptions.ConfigurationExecutionError: <type 'exceptions.TypeError'>: object.__new__() takes no parameters
in:
Line 80 of file /Workspace/Personal/project/.env/local/lib/python2.7/site-packages/pyramid/events.py:
config.add_subscriber(wrapped, iface, **self.predicates)
我也有同樣的方式註冊自定義視圖謂詞,它工作得很好,所以我不知道我在做什麼錯在這裏。
老實說,我無法找到我哪裏錯了,但感謝。 – BDuelz