[Zope-CMF] question: changing the portal_type

Dieter Maurer dieter@handshake.de
Wed, 12 Jun 2002 20:11:04 +0200


Roel Van den Bergh writes:
 > I would like to write a script that changes the content of a folder to a
 > specific portal_type but I do not know where to start.
There is a (private) method "_setPortalTypeName" that allows you
to set the "portal type name". You can only call it in an
External Method (or other unrestricted code), as it is private.

You can use "ZopeFind" (or a catalog search) to select the objects
to be retyped and then call the External Method on those objects.

However, changing the portal type is not without risks...

Probably a better approach is a (so called) Monkey patch
the modifies the "File" object and gives it a new "icon" method.

Search Zope.org for "monkey". You should find documents that describe
how to make such patches.


Dieter