[Zope-dev] advice on MountedFileStorage changes.

Anthony Baxter Anthony Baxter <anthony@interlink.com.au>
Sun, 11 Jun 2000 17:43:40 +1000


>>> Anthony Baxter wrote
> 
> I've nearly completed the code to make MountedFileStorage able to 
> create new FileStorages on demand, _however_... 
> 
> I'm hitting a bit of a problem with the Product initialisation. Right
> now I'm just calling OFS.Application.initialize(), which goes through
> and re-imports all the products, and adds them to the global meta_types
> list. This is bad - it means it's slow as hell reimporting everything, 
> and everything gets listed twice. It's fine after a restart, but that's 
> not much help.

Ok, I've gone with the 'subclass Application' approach, and made a 
couple of slight changes to the core code. Now, stuff won't be added
to global registries like Products.meta_types if the application doesn't
have isTopLevelPrincipiaApplicationObject set to true. 

It seems to work well, patch follows - any comments?

Anthony.

This patch (against current CVS, 2000-06-11) stops the addition of a new
MountedFileStorage adding all the products to the master meta_types list.
It's not _essential_, but without it, you'll find you need to restart Zope
to get the 'Add' list back to sanity.

Index: OFS/Application.py
===================================================================
RCS file: /cvs-repository/Zope2/lib/python/OFS/Application.py,v
retrieving revision 1.128
diff -u -r1.128 Application.py
--- Application.py      2000/06/09 23:52:45     1.128
+++ Application.py      2000/06/11 07:00:30
@@ -511,7 +511,8 @@
                     error=sys.exc_info())
                 get_transaction().abort()
 
-    Products.meta_types=Products.meta_types+tuple(meta_types)
+    if app.isTopLevelPrincipiaApplicationObject:
+       Products.meta_types=Products.meta_types+tuple(meta_types)
 
     Globals.default__class_init__(Folder)
 
Index: App/ProductContext.py
===================================================================
RCS file: /cvs-repository/Zope2/lib/python/App/ProductContext.py,v
retrieving revision 1.22
diff -u -r1.22 ProductContext.py
--- ProductContext.py   2000/06/09 01:22:13     1.22
+++ ProductContext.py   2000/06/11 07:00:30
@@ -202,12 +202,13 @@
         if not hasattr(pack, '_m'): pack._m={}
         m=pack._m
 
-        Products.meta_types=Products.meta_types+(
-            { 'name': meta_type or instance_class.meta_type,
-              'action': ('manage_addProduct/%s/%s' % (pid, name)),
-              'product': pid,
-              'permission': permission,
-              },)
+       if app.isTopLevelPrincipiaApplicationObject:
+           Products.meta_types=Products.meta_types+(
+               { 'name': meta_type or instance_class.meta_type,
+                 'action': ('manage_addProduct/%s/%s' % (pid, name)),
+                 'product': pid,
+                 'permission': permission,
+                 },)
 
         m[name]=initial
         m[name+'__roles__']=pr