[Zope-CMF] child class behaves like PortalFolder

Florent Guillaume fg@nuxeo.com
Wed, 20 Mar 2002 17:15:08 +0000 (UTC)


Also please see http://www.zope.org/Products/PTK/Tracker/483, there is a
bug in listFolderContents for objects with portal_type != meta_type
(which is supposed to be one of the main selling points of the Types Tool :-).

Florent



Tres Seaver  <tseaver@zope.com> wrote:
> Jens Wolk wrote:
> > It seems as if the object is created as a "PortalFolder", not a 
> > "zypCategory": in the portal_types tool I set an icon for the zypCategory 
> > class, but still the normal folder icon is shown. If I look at the folder 
> > contents of the folder in which the zypCategory object lies, and set the View 
> > Filter to show only "zypCategory", it is not listed. However, if I select 
> > "Folder" instead, it is listed.
> > 
> > Why might this be so?
> Somehow the 'portal_type' of your instances is not being set;
> are you creating them via the stock 'folder_factories' form?
> Or are these objects created by some other process?  As a check,
> use your browser to call the 'Type' method of one of your objects
> (i.e., append '/Type' to the URL):  I am sure it will return "Folder".
> 
> If you aren't constructing instances of your type via 'invokeFactory'
> on its container, then you likely need to mimic what it does;  in
> particular, you will need to call '_setPortalTypeName' on the new
> instance.  If you don't intend for your class ever to be used as a
> base for more than one type, you could also add a shared attribute,
> 'portal_type', to the class, e.g.::
> 
>    class zypCategory (PortalFolder, DefaultDublinCoreImpl):
>        """
>        a zyp category
>        """
> 
>        meta_type = 'CMF zyp Category'
>        portal_type = 'zypCategory'
>        #...
-- 
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 10  http://nuxeo.com  mailto:fg@nuxeo.com