2012-03-02 62 views
0

我遇到了FS控制器頁面模板的問題。我有這個Plone2基礎產品,我在做Plone 4.2遷移時已經可以蛋化了。下面我貼了回溯。AccessControl不支持使用具有級別規範的導入:_warnings

Traceback (innermost last): 
    Module ZPublisher.Publish, line 126, in publish 
    Module ZPublisher.mapply, line 77, in mapply 
    Module ZPublisher.Publish, line 46, in call_object 
    Module Products.CMFFormController.FSControllerPageTemplate, line 91, in __call__ 
    Module Products.CMFFormController.BaseControllerPageTemplate, line 26, in _call 
    Module Products.CMFFormController.FormController, line 384, in validate 
    Module ZPublisher.mapply, line 77, in mapply 
    Module ZPublisher.Publish, line 46, in call_object 
    Module Products.CMFFormController.FSControllerValidator, line 58, in __call__ 
    Module Products.CMFFormController.Script, line 145, in __call__ 
    Module Products.CMFCore.FSPythonScript, line 130, in __call__ 
    Module Shared.DC.Scripts.Bindings, line 322, in __call__ 
    Module Shared.DC.Scripts.Bindings, line 359, in _bindAndExec 
    Module Products.PythonScripts.PythonScript, line 344, in _exec 
    Module script, line 32, in exams_list 
    - <FSControllerValidator at /dev/exam/online/booking/validators/exams_list> 
    - Line 32 
    Module AccessControl.ZopeGuards, line 299, in guarded_import 
Unauthorized: Using import with a level specification isn't supported by AccessControl: _warnings 

上exams_list驗證線32與astric

if event and not state.getErrors(): 
    try: 
    context.script.validateEvent() 
    except ValueError,exc: 
    state.setError('SIMSError',str(exc)) 
    **except 'dryrun':** 
    state.setStatus('dryrun') 

任何幫助或指針總是有益的包裹。

回答

1

從Python 2.6中刪除了對字符串異常的支持;您需要使用適當的例外類'dryrun'來代替。

您需要將該異常標記爲可通過受限代碼導入,然後才能將其導入到Controller腳本中。

下面是這樣一個例外的例子定義:

from AccessControl.SecurityInfo import ModuleSecurityInfo 

security = ModuleSecurityInfo('My.Product.exceptions') 

security.declarePublic('DryRunException') 
class DryRunException(Exception): 
    '''The process was not committed, this was only a dry run''' 

隨着地方ModuleSecurityInfo信息,您現在可以導入此異常到腳本:

from My.Product.exceptions import DryRunException 

和捕捉,與其在你的except區塊;當然,拋出這個異常的代碼也需要更新。

+0

謝謝你的時間。 – WEBBYFOX 2012-03-06 12:10:35