[Zope-CMF] Extending a Plone Object

Raphael Ritz r.ritz@biologie.hu-berlin.de
Fri, 21 Feb 2003 16:38:48 +0100


Florent Guillaume wrote:

>There is a very easy way to do this built into CMF, the Scriptable Type
>Information.
>
>In the Types Tool, create a new Scriptable Type Information, deriving it
>from the base type you need. Name it "MyType" for instance. As
>"Constructor path", type the name of a Python Script, for instance
>MyType_create. Create this Python Script in the Types Tool:
>
>##parameters=container, id, *args, **kw
># create the base object
>container.invokeFactory('Some Base Portal Type', id)
>ob = getattr(container, id)
># now add the properties you need
>ob.manage_addProperty('foo', 1, 'int')
># finally return the object
>return ob
>
>The only thing you have to be aware of is that during script execution,
>the portal_type of your object will be the base portal type and not yet
>the one of your final type.
>
Shame on me. I didn't know that (more precisely: I never managed
to figure out how to make sensible use of the scriptable type).

Thanks a lot!

Raphael

>
>Florent
>  
>