[Zope-dev] Manipulating Meta-Type Global Add list on per-instance basis

Tres Seaver tseaver@palladion.com
Tue, 29 Feb 2000 16:01:42 -0600


Josh Zeidner <jmz_phylogenic@hotmail.com> asks:

>   I am currently trying to define a Z-Class that inherits from Object
> Manager that has the special behavior of being able to change its "allowable
> sub-objects" on a per-instance basis.
> 
> *****************
> 
> ex.
> 
>   I instantiate the class at a particular location I want this object to
> only be able to contain objects of type "AppleObject" and "OrangeObject".
> 
>   I instantiate the class at another location and I want this object to only
> contain objects of type "LemonObject" and "LimeObject".
> 
>   note that the difference here is that both of the containers are of the
> same type.
> 
> *************
> 
>   is it possible to have this flexibility after the ZClass has been defined?

If you are defining the interface (rather than accepting the default "Contents"
view), then you can do something like::

 <select name="toAdd">
   <dtml-in "filtered_meta_types( AUTHENTICATED_USER )" mapping>
     <dtml-if "name in allowed_types">
       <option value="&dtml-name;"> <dtml-var name>
     </dtml-if>
   </dtml-in>
 </select>

where 'allowed_types' is a tokens/lines property of the instance.

Making this happen in the stock management interface is trickier -- you need to
overried either all_meta_types(), but finding the list of possible types, so
that the list you return contains the dictionaries required by
filtered_meta_types().  I can't see easily off hand how to do this from within a
Python Method -- I think I would have to drop down to an External Method, or
create a new Python base class to implement this.

Tres.
-- 
=========================================================
Tres Seaver         tseaver@palladion.com    713-523-6582
Palladion Software  http://www.palladion.com