"Local" classes in Python based products (was: [Zope] Creates classes available to container but NOT add products menu)

Dieter Maurer dieter@handshake.de
Thu, 7 Mar 2002 21:05:14 +0100


chrisf writes:
 > ...
 > I have a heap of classes. I do not want every class in the add Products
 > menu.
 > I do want them to be available to the top level container class.
Not sure what is "the top level container class", but I expect
your want something like

     class MyTopLevelContainerClass(....):
       def all_meta_types(self):
         return (
	   {'name' : SUBTYPE1, 'action' : CONSTRUCTOR1, 'permission' : PERM1,},
	   {'name' : SUBTYPE2, 'action' : CONSTRUCTOR2, 'permission' : PERM2,},
	   {'name' : SUBTYPE3, 'action' : CONSTRUCTOR3, 'permission' : PERM3,},
	   .....
	   )
What's returned by "all_meta_types" is a sequence of product dispatchers.
Each element describes one entry in the add list.
"SUBTYPEi" is what you see in the add list entry (usually the meta type),
"CONSTRUCTORi" is the name of the contructor (which of course must
be accessible from your "MyTopLevelContainerClass" instance).
"PERMi" is the permission name protecting the constructor.
A user will see the entry only when he has this permission.


For your future approaches: this already has been discussed in the
mailing lists, maybe not as clear as above (that's the reason, why
I do it again...). Searching the mailing list archives probably
would have revealed the solution.


Dieter