On Thu, 2006-04-05 at 10:43 +0200, Stefan H. Holek wrote:
> Note that Zope2.app() opens a new ZODB connection which you need to  
> close at some point. I suggest something along the lines of:
> 
>       app = Zope2.app()
>          try:
>               products = app.Control_Panel.Products
>               ...
>       finally:
>               app._p_jar.close()
> 
> I am also wondering if this code would break if a product was removed  
> from the file system, but still had its persistent part hanging  
> around in Control_Panel.Products.

Hmm... good points, I'll look into this.


- Rocky



> On 2. Mai 2006, at 22:59, Rocky Burt wrote:
> 
> > Log message for revision 67869:
> >   External methods can now live outside of Products based python  
> > packages.
> >
> > Changed:
> >   U   Zope/trunk/lib/python/App/FactoryDispatcher.py
> >
> > -=-
> > Modified: Zope/trunk/lib/python/App/FactoryDispatcher.py
> > ===================================================================
> > --- Zope/trunk/lib/python/App/FactoryDispatcher.py  2006-05-02  
> > 20:57:53 UTC (rev 67868)
> > +++ Zope/trunk/lib/python/App/FactoryDispatcher.py  2006-05-02  
> > 20:59:07 UTC (rev 67869)
> > @@ -13,12 +13,36 @@
> >
> >
> >  # Implement the manage_addProduct method of object managers
> > +import types
> >  import Acquisition, sys, Products
> >  from Globals import InitializeClass
> >  from AccessControl import ClassSecurityInfo
> >  from AccessControl.PermissionMapping import aqwrap
> >  from AccessControl.Owned import UnownableOwner
> > +import Zope2
> >
> > +def _product_packages():
> > +    """Returns all product packages including the regularly defined
> > +    zope2 packages and those without the Products namespace package.
> > +    """
> > +
> > +    old_product_packages = {}
> > +    for x in dir(Products):
> > +        m = getattr(Products, x)
> > +        if isinstance(m, types.ModuleType):
> > +            old_product_packages[x] = m
> > +
> > +    packages = {}
> > +    products = Zope2.app().Control_Panel.Products
> > +    for product_id in products.objectIds():
> > +        product = products[product_id]
> > +        if hasattr(product, 'package_name'):
> > +            packages[product_id] = __import__(product.package_name)
> > +        elif old_product_packages.has_key(product_id):
> > +            packages[product_id] = old_product_packages[product_id]
> > +
> > +    return packages
> > +
> >  class ProductDispatcher(Acquisition.Implicit):
> >      " "
> >      # Allow access to factory dispatchers
> > @@ -32,7 +56,7 @@
> >
> >          # Try to get a custom dispatcher from a Python product
> >          dispatcher_class=getattr(
> > -            getattr(Products, name, None),
> > +            _product_packages().get(name, None),
> >              '__FactoryDispatcher__',
> >              FactoryDispatcher)
> >
> >
> > _______________________________________________
> > Checkins mailing list
> > [EMAIL PROTECTED]
> > http://mail.zope.org/mailman/listinfo/checkins
> 
> --
> Anything that happens, happens.  --Douglas Adams
> 
> 
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev@zope.org
> http://mail.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists - 
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope )
> 
-- 
Rocky Burt
ServerZen Software -- http://www.serverzen.com
News About The Server -- http://www.serverzen.net


_______________________________________________
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )

Reply via email to