[Zope-CMF] child class behaves like PortalFolder

Tres Seaver tseaver@zope.com
Wed, 20 Mar 2002 09:31:57 -0500


Jens Wolk wrote:
> Am Mittwoch, 20. M=E4rz 2002 13:28 schrieben Sie:
>=20
> [...]
>=20
>=20
>> > However, my folderish "CMF zyp Category" behaves like it was a
>> > PortalFolder (its parent class) and I don't know why. (If I - for ex=
ample
>> > - click on "Edit" for the object myZypCategory then
>> > myZypCategory/folder_edit_form is called instead of
>> > myZypCategory/zyp_category_edit_form)
>=20
>=20
> [...]
>=20
>=20
>> > I hesitate to add white noise to this ML by posting the complete
>> > sourcecode. So please point your browser to
>> > http://www.jenswolk.de/zypContentCategory.htm
>=20
>=20
>> That looks OK;  please look at the "Actions" tab of your 'zypCategory'
>> type object and see what values are in the fields there.  If they stil=
l
>> have the "stock" values for folders, then you should re-create the
>> type object:
>=20
>=20
> Thank you for your hint. The settings here seem to be OK (pointing to t=
he=20
> right *.dtml files).=20
>=20
>=20
>>    - Delete your 'zypCategory' object from the types tool.
>>    - Re-add it, using your product's type as a base.
>=20
>=20
> I did that, just to be sure. But it's still the same thing. (For new=20
> instances, too)
>=20
> It seems as if the object is created as a "PortalFolder", not a=20
> "zypCategory": in the portal_types tool I set an icon for the zypCatego=
ry=20
> class, but still the normal folder icon is shown. If I look at the fold=
er=20
> contents of the folder in which the zypCategory object lies, and set th=
e View=20
> Filter to show only "zypCategory", it is not listed. However, if I sele=
ct=20
> "Folder" instead, it is listed.
>=20
> 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 =3D 'CMF zyp Category'
       portal_type =3D 'zypCategory'
       #...

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