[ZDP] BackTalk to Document Zope Developer's Guide (2.4 edition)/Zope Products

webmaster@zope.org webmaster@zope.org
Sun, 23 Feb 2003 03:05:20 -0500


A comment to the paragraph below was recently added via http://www.zope.org/Documentation/Books/ZDG/current/Products.stx#4-35

---------------

        If you wish to control which types of objects can be contained
        by instances of your product you can set the 'meta_types' class
        attribute. This attribute should be a tuple of meta_types. This
        keeps other types of objects from being created in or pasted
        into instances of your product. The 'meta_types' attribute is
        mostly useful when you are creating specialized container
        products.

          % Anonymous User - Mar. 27, 2002 8:04 pm - And what is 'a tuple of meta_types' ? A tuple of strings doesn't work...

          % Anonymous User - June 19, 2002 10:09 am:
           The following seems to work:

           meta_types = ( { 'name' : 'Image', 'action' : 'manage_addImageForm', 'permission' : 'Add Image' } , )

           Then you need to define the action 'manage_addImageForm' in your class:

           from OFS.Image import Image
           manage_addImageForm = Image.manage_addImageForm

          % Anonymous User - Sep. 16, 2002 8:56 pm:
           This method appears to add an object type, not restrict the types that can
           be contained.  Does anyone have a method that actually works properly in Zope 
           2.5.1?

          % Anonymous User - Nov. 8, 2002 7:49 pm:
           When making a special container product with a specialized set of addable
           components (e.g. a report document with included db-generated images)
           which should themselves be like products,
           it maybe desired that these component products should be registered in the
           container class only and not in zope, the main effect of this is that 
           these component products wont appear in ordinary zope folder add lists
           and are only addable in the master container and nowhere else.
           It would be nice to have this specialized product registry explained also. blf

          % Anonymous User - Feb. 23, 2003 3:05 am:
           Here's a solution seems to work:
           all_meta_types = ( { 'name' : 'Image', 'action' : 'manage_addImageForm', 'permission' : 'Add Image' } , )

           Now the add-list will only show the products specified.