[Zope] Allow to import a function on protected code

Winterflood, Jonathan jonathan.winterflood at capgemini.com
Thu Jun 21 10:09:47 EDT 2007


Hi,

 

I believe you should write

modulesecurity = ModuleSecurityInfo('Products.Product'sDirectory.Module'sName')

 

You may or may not need

modulesecurity.apply (globals())

What should it do?

 

Jonathan

________________________________

De : zope-bounces at zope.org [mailto:zope-bounces at zope.org] De la part de Garito
Envoyé : jeudi 21 juin 2007 15:02
À : Zope user list
Objet : [Zope] Allow to import a function on protected code

 

Hi!
I write this module in a Product (I import some module's functions in the product):

from AccessControl import ModuleSecurityInfo
modulesecurity = ModuleSecurityInfo()

def metodo(argumentos):
  here goes the method's code

modulesecurity.declarePublic('metodo')

modulesecurity.apply (globals())

Then I try to import in a Script Python like:

from Products.Product'sDirectory.Module'sName import metodo

But fails (ImportError)

I try to add to the module's code allow_module('metodo') with the same result 

I try to import from Products.Product'sDirectory import metodo in the same way I can Import FormValidationError (from Products.Formulator.Form import FormValidationError where FormValidationError is on Errors.py not in Form.py) but I have the same result (ImportError again)

Can you point me where is the mistake?

This is the traceback for more clues:

Traceback (innermost last):

  Module ZPublisher.Publish
, line 115, in publish

  Module ZPublisher.mapply, line 88, in mapply

  Module ZPublisher.Publish, line 41, in call_object

  Module Products.Yanged.Yanged, line 166, in index_html

  Module Products.Yanged.Yanged
, line 207, in __call__

  Module Products.Yanged.Yanged, line 234, in Ejecutar

  Module Products.Yanged.Yanged, line 207, in __call__

  Module Products.Yanged.Yanged, line 234, in Ejecutar

  Module Products.Yanged.Yanged
, line 207, in __call__

  Module Products.Yanged.Yanged, line 234, in Ejecutar

  Module Products.Yanged.Yanged, line 207, in __call__

  Module Products.Yanged.Yanged, line 234, in Ejecutar

  Module Products.Yanged.Yanged
, line 190, in __call__

  Module Products.Yanged.Yanged, line 234, in Ejecutar

  Module Shared.DC.Scripts.Bindings, line 311, in __call__

  Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec

  Module 
Products.PythonScripts.PythonScript, line 326, in _exec

  Module None, line 1, in ResolverEquivalencias

   - <PythonScript at /sistes.net/clientes/escobarsl.com/Comandos/ResolverEquivalencias used for /sistes.net/clientes/escobarsl.com/Pagina/Editar/Sincronizar/ObtenerCaso/EditarArea/ResolverEquivalencias>


   - Line 1

  Module AccessControl.ZopeGuards, line 266, in guarded_import

  Module AccessControl.ZopeGuards, line 329, in load_module

Unauthorized: You are not allowed to access 'freemind' in this context
 


Thanks a lot! And sorry if I forget something :)
-- 
Mis Cosas
http://blogs.sistes.net/Garito 



This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient,  you are not authorized to read, print, retain, copy, disseminate,  distribute, or use this message or any part thereof. If you receive this  message in error, please notify the sender immediately and delete all  copies of this message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope/attachments/20070621/567012e4/attachment.htm


More information about the Zope mailing list