[Zope-CMF] dynamic list of content-types for the zope ZMI

Tres Seaver tseaver@zope.com
Mon, 07 Jan 2002 14:21:57 -0500


Oliver Bleutgen wrote:

> Hi,
> 
> I'm trying to find my way through the API for CMF filesystem products.
> Bjorn Stabell pointed out to me how to use portal_types + portal_skins 
> to get a fixed product with changeable "templates".
> 
> What I want to do is to write a product which can be added through the 
> ZMI (not the CMF GUI) and where the user can select which template
> it will use (through selecting the portal_type).
> 
> The problem is now that I can't know beforehand which different 
> portal_types will be based on an object of that meta_type, and I'd like 
> to dynamically gather that list at the moment the user wants to add an 
> instance.
> 
> AFAIK, CMF-products use CMFCore.utils.manage_addContentForm(), which 
> knows about the content_types lastly from utils.ContentInit(...),
> done in the products __init__.py, where content_types = 
> (tuple_of_objects,) is passed.
> 
> Is there a way to stay within the framework (i.e. still use 
> utils.manage_addContentForm) and get the addForm to show the 
> content_types dynamically? Using ComputedAttribute perhaps?


Have a look at how the 'folder_factories' skin method does it

(basically, it acquires the 'portal_types' tool and then queries
it for type information objects).

Tres.
-- 
===============================================================
Tres Seaver                                tseaver@zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com