[Zope] Module security assertions fail

Josef Albert Meile jmeile at hotmail.com
Sat May 1 11:31:17 EDT 2004


sorry if you see this message twice, but I posted it yesterday and didn't 
found it on the list today.

So here goes it again:

I have two packages "TranslationUtils" and "JMZPTMacros", which I want to 
use from a zope product. I have implemented the module and class security 
assertions as indicated on the Zope Developer's Gide, but I got always an 
Unauthorized error (see the traceback attached at the bottom of this 

Here is the structure:

* Some metal macros I want to use with my Products:

* Some calls to the avalaible Translation services:

* Zope product, which uses the previous packages:

I've had success with JMZPTMacros, but not with TranslationUtils.

Here is what I have done (Please note that I put some extra dashes at the 
begining of the lines, where the indentation is required):

----->Begin of MyInstanceHome/Products/JMUtils/__init__.py


from Products.PythonScripts.Utility import allow_module, allow_class

#JMZPTMacros has a class inside. On the contrary,
#TranslationUtils is only a package of functions
from Products.JMUtils.JMZPTMacros import JMZPTMacros

----->End of MyInstanceHome/Products/JMUtils/__init__.py

----->Begin of MyInstanceHome/Products/JMUtils/JMZPTMacros.py

from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from AccessControl import ClassSecurityInfo
import Globals

class JMZPTMacros:


--#The same was done with the rest of my templates on
--#the zpt directory of JMUtils

# finally

----->End of MyInstanceHome/Products/JMUtils/JMZPTMacros.py

----->Begin of MyInstanceHome/Products/JMUtils/TranslationUtils.py

from AccessControl import ModuleSecurityInfo

def checkTranslationService():
--"""Some code comes here

#The same was done for the rest of the functions on this package


----->End of MyInstanceHome/Products/JMUtils/TranslationUtils.py

Then I have a manage_add page template with the following line inside:

  <span tal:define="TranslationUtils 
    Something comes here

When I try to add the product on the zope manage interface, I get:

Traceback (innermost last):
  Module ZPublisher.Publish, line 100, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 40, in call_object
  Module Products.JMColorPicker.JMColorPicker, line 24, in 
  Module Shared.DC.Scripts.Bindings, line 306, in __call__
  Module Shared.DC.Scripts.Bindings, line 343, in _bindAndExec
  Module Products.PageTemplates.PageTemplateFile, line 106, in _exec
  Module Products.PageTemplates.PageTemplate, line 96, in pt_render
   - <PageTemplateFile at /temp/JMColorPicker_Add>
  Module TAL.TALInterpreter, line 189, in __call__
  Module TAL.TALInterpreter, line 233, in interpret
  Module TAL.TALInterpreter, line 663, in do_useMacro
  Module TAL.TALInterpreter, line 233, in interpret
  Module TAL.TALInterpreter, line 406, in do_optTag_tal
  Module TAL.TALInterpreter, line 388, in no_tag
  Module TAL.TALInterpreter, line 233, in interpret
  Module TAL.TALInterpreter, line 459, in do_setLocal_tal
  Module Products.PageTemplates.TALES, line 220, in evaluate
   - URL: generic_add
   - Line 20, Column 2
   - Expression: standard:'modules/Products/JMUtils/TranslationUtils'
   - Names:
      {'container': <__FactoryDispatcher__ instance at 9751938>,
       'context': <__FactoryDispatcher__ instance at 9751938>,
       'default': <Products.PageTemplates.TALES.Default instance at 
       'here': <__FactoryDispatcher__ instance at 9751938>,
       'loop': <SafeMapping instance at 8778eb0>,
       'modules': <Products.PageTemplates.ZRPythonExpr._SecureModuleImporter 
instance at 0x8b47c1c>,
       'nothing': None,
       'options': {'Kind': 'JMColorPicker', 'args': ()},
       'repeat': <SafeMapping instance at 8778eb0>,
       'request': <HTTPRequest, 
       'root': <Application instance at 8999b40>,
       'template': <PageTemplateFile at /temp/JMColorPicker_Add>,
       'traverse_subpath': [],
       'user': admin}
  Module Products.PageTemplates.Expressions, line 201, in __call__
  Module Products.PageTemplates.Expressions, line 189, in _eval
  Module Products.PageTemplates.Expressions, line 145, in _eval
   - __traceback_info__: modules
  Module Products.PageTemplates.Expressions, line 340, in restrictedTraverse
   - __traceback_info__: {'path': ['Products', 'JMUtils', 
'TranslationUtils'], 'TraversalRequestNameStack': []}
Unauthorized: You are not allowed to access 'TranslationUtils' in this 

But if I create the following pythonscript (no parameters and return value 
were given):

from Products.JMUtils import TranslationUtils

then I hit the test tab and try again to create an instance of my product, 
it will magically work till zope is restarted. Am I missing something?

Thanks in advanced,
Josef Meile

Add photos to your e-mail with MSN 8. Get 2 months FREE*. 

More information about the Zope mailing list