2012-03-02 61 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