[Zope] Re: strategies for using external py packages

Tres Seaver tseaver at zope.com
Fri Oct 1 12:45:00 EDT 2004


Jim Abramson wrote:
> Thanks, Tres, for your quick reply.  Might I ask a followup question (you may refer me to some existing docs as well, that'd be great) -  
> 
> In the past I've messed with simply having a Script (Python) that goes:
> 
> from Products.MyProduct.mymodule import mymethod
> result = mymethod.dosomething()
> 
> ...this is without having any kind of proper 'instance' of the Product in my Zope instance.  It's worked, though a) it's kinda messy, and b) I've never really been able to determine if this exposes me to memory leak problems (so far so good) or has other negative impacts or risks.
> 
> How do things differ between this 'lo-fi' approach, and that of explicitly instantiating the Product somewhere in my Zope tree as you suggested?

PythonScripts can't access stuff in modules without security assertions 
(which is a good thing).  You could perhaps make such assertions 
yourself somewhere (e.g., in your own product)::

   from AccessControl import ModuleSecurityInfo
   security = ModuleSecurityInfo('my.exernal.package')
   security.declarePublic('know_safe_method')

Adding the proxy object allows you to remap (if needed) APIs from the 
underlying library (e.g., to return values which play nice with ZPT)

Tres.
-- 
===============================================================
Tres Seaver                                tseaver at zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com


More information about the Zope mailing list