[z3-five] can't import an interface into a page template

Tim Hicks tim at sitefusion.co.uk
Tue Nov 16 21:56:02 MET 2004


I'm trying to get hold of an interface (of the zope3 variety) from a zpt
so that I can adapt to it. So, my zpt has::

  <tal:dummy define="IMessageFlags
modules/Products.atemail.interfaces.IMessageFlags">

However, no matter how I declare security, I cannot manage to import
IMessageFlags.  I have tried the following in the product __init__.py::

  from Products.PythonScripts.Utility import allow_module, allow_class

followed by either::

  allow_module('interfaces')

or::

  allow_module('Products.atemail.interfaces')

The end of the traceback I get when I view the zpt is::

    mod = safe_builtins['__import__'](module)
  File "/home/tim/zope/2.8-pre/lib/python/AccessControl/ZopeGuards.py",
line 281, in guarded_import
    module = load_module(None, None, mnameparts, validate, globals, locals)
  File "/home/tim/zope/2.8-pre/lib/python/AccessControl/ZopeGuards.py",
line 344, in load_module
    if module and not validate(module, module, nextname, nextmodule):
Unauthorized: You are not allowed to access 'interfaces' in this context

When I try::

  allow_class('interfaces.IMessageFlags')

I get the following traceback upon zope startup::

Traceback (most recent call last):
  File "/home/tim/zope/2.8-pre/lib/python/Zope/Startup/run.py", line 56, in ?
    run()
  File "/home/tim/zope/2.8-pre/lib/python/Zope/Startup/run.py", line 21,
in run
    starter.prepare()
  File "/home/tim/zope/2.8-pre/lib/python/Zope/Startup/__init__.py", line
96, in prepare
    self.startZope()
  File "/home/tim/zope/2.8-pre/lib/python/Zope/Startup/__init__.py", line
252, in startZope
    Zope.startup()
  File "/home/tim/zope/2.8-pre/lib/python/Zope/__init__.py", line 47, in
startup
    _startup()
  File "/home/tim/zope/2.8-pre/lib/python/Zope/App/startup.py", line 46,
in startup
    OFS.Application.import_products()
  File "/home/tim/zope/2.8-pre/lib/python/OFS/Application.py", line 638,
in import_products
    import_product(product_dir, product_name, raise_exc=debug_mode)
  File "/home/tim/zope/2.8-pre/lib/python/OFS/Application.py", line 661,
in import_product
    product=__import__(pname, global_dict, global_dict, silly)
  File "/home/tim/zope/2.8instance/Products/atemail/__init__.py", line 22,
in ?
    allow_class('interfaces.IMessageFlags')
  File "/home/tim/zope/2.8-pre/lib/python/AccessControl/SecurityInfo.py",
line 309, in allow_class
    Class._security = sec = ClassSecurityInfo()
AttributeError: 'str' object has no attribute '_security'


Am I doing something silly (that should be posted on zope at zope.org) or is
there something else wrong?

Alternatively, is there another way around this?

Thanks,

tim


More information about the z3-five mailing list