2011-04-24 74 views
3

我在金字塔中創建應用時遇到了問題。當我嘗試通過貼紙服務時,我得到:金字塔配置加載錯誤

File "/home/viraptor/blah/blah/__init__.py", line 23, in main 
    return config.make_wsgi_app() 
    File "/home/viraptor/pyramid/lib/python2.6/site-packages/pyramid/config.py", line 916, in make_wsgi_app 
    self.commit() 
    File "/home/viraptor/pyramid/lib/python2.6/site-packages/pyramid/config.py", line 491, in commit 
    self._ctx.execute_actions() 
    File "/home/viraptor/pyramid/lib/python2.6/site-packages/zope/configuration/config.py", line 626, in execute_actions 
    callable(*args, **kw) 
    File "/home/viraptor/pyramid/lib/python2.6/site-packages/pyramid/config.py", line 1291, in register 
    derived_view = deriver(view) 
    File "/home/viraptor/pyramid/lib/python2.6/site-packages/pyramid/config.py", line 2681, in __call__ 
    self.mapped_view(view)))))))) 
    File "/home/viraptor/pyramid/lib/python2.6/site-packages/pyramid/config.py", line 2624, in inner 
    wrapped_view = wrapped(self, view) 
    File "/home/viraptor/pyramid/lib/python2.6/site-packages/pyramid/config.py", line 2693, in mapped_view 
    mapped_view = mapper(**self.kw)(view) 
    File "/home/viraptor/pyramid/lib/python2.6/site-packages/pyramid/config.py", line 2860, in __call__ 
    view = self.map_nonclass(view) 
    File "/home/viraptor/pyramid/lib/python2.6/site-packages/pyramid/config.py", line 2876, in map_nonclass 
    ronly = requestonly(view, self.attr) 
    File "/home/viraptor/pyramid/lib/python2.6/site-packages/pyramid/config.py", line 2966, in requestonly 
    if len(args) - len(defaults) == 1: 
zope.configuration.config.ConfigurationExecutionError: <type 'exceptions.TypeError'>: object of type 'NoneType' has no len() 
    in: 
    ('/home/viraptor/blah/blah/__init__.py', 22, 'main', "config.add_route('customer', '/customer/{customer_id}', view='blah.views.customer.view', view_renderer='customer_view.mak', view_permission='view', traverse='/customer/{customer_id}')") 

這是什麼原因?我最近甚至沒有改變這個配置,只有應用的其他部分。

+0

你沒有包含實際的異常,只有堆棧跟蹤。沒有人知道現在發生了什麼,只有在...... :-) – 2011-04-24 10:37:24

+0

@Martijn Pieters - Python在最後打印異常 - 它在那裏。這是ConfigurationExecutionError。 – viraptor 2011-04-24 10:41:47

+0

啊,我的錯,我iPhone上的移動視圖沒有顯示整個文本,我也沒有跡象表明它更長。道歉! – 2011-04-24 10:50:58

回答

3

我懷疑你遇到了金字塔更新版本中修復的錯誤;您的回溯表明argsdefaultsNone,但該代碼分支無法到達,除非args不是None,這樣可能代之以defaults而不是None。我發現下面的承諾金字塔,增加了一個具體的測試defaults是無:

https://github.com/Pylons/pyramid/commit/f168197609169fb01b65adeb3eb59d069000fe2c

我說你有沒有任何違約的方法只有一個請求參數(method(self, request),工作,各地將添加關鍵字參數使用默認的(method(self, request, dummy=None)

免責聲明:。尚未有機會與金字塔的工作,所以我的分析是完全基於金字塔代碼庫

0

config.add_route只接受1位置ARG你的第二個參數應該用pattern來表示密鑰。

其次,我不認爲有可能有相同的模式routetraverse。使用traverse關鍵字,您可以確定root應該在哪裏啓動。這在Configurator API documentation中有解釋。

雖然提出的錯誤異常可能會提供更多信息。

+0

在混合方法中使用樹時,在URL調度中使用類似traverse =和pattern =參數是完全有效的。另外,雖然模式是add_route中的關鍵字參數,但基本上所有文檔都將其視爲位置參數。 – 2011-04-24 19:02:43