[Zope-dev] allow_module broken in Zope 2.5?

Casey Duncan c.duncan@nlada.org
Wed, 16 Jan 2002 18:06:48 -0500


I am working on a patch for Formulator so that its exception classes can be 
imported into a Python Script. the following code works for Zope 2.3 and 2.4 
but I get an unauthorized error when I try to import from this in 2.4 (Just 
tested b4, but not CVS). Here is the code from the module Errors.py in the 
Formulator product package dir:
----
"""Exception Classes for Formulator"""

# These classes are placed here so that they can be imported into TTW Python
# scripts. To do so, add the following line to your Py script:
# from Products.Formulator.Errors import ValidationError, FormValidationError

from Products.PythonScripts.Utility import allow_module, allow_class

allow_module('Products.Formulator.Errors')

class FormValidationError(Exception):

    def __init__(self, errors, result):
        Exception.__init__(self,"Form Validation Error")
        self.errors = errors
        self.result = result
        
allow_class(FormValidationError)

class ValidationError(Exception):
    
    def __init__(self, error_key, field):
        Exception.__init__(self, error_key)
        self.error_key = error_key
        self.field_id = field.id
        self.field = field
        self.error_text = field.get_error_message(error_key)

allow_class(ValidationError)
----

If you create a python script containing:
from Products.Formulator.Errors import ValidationError, FormValidationError

You get an Unauthorized exception in 2.5, but not in 2.4 or 2.3. I realize 
this should probably go in the collector, but I wanted to make sure I wasn't 
doing something dumb first. Thanks.

/---------------------------------------------------\
  Casey Duncan, Sr. Web Developer
  National Legal Aid and Defender Association
  c.duncan@nlada.org
\---------------------------------------------------/