[Zope-CMF] Extending a Plone Object

David Rawle david@rawle.org.uk
Fri, 21 Feb 2003 15:54:04 -0000


That worked beautifully...thank you so much. I have a new portal type based
on Event...easy when you know how, huh?

Cheers,

- David

---
David Rawle
Checked for Viruses with Norton AntiVirus
Secure Crytographic Signature (S/MIME) may be attached

----- Original Message -----
From: "Florent Guillaume" <fg@nuxeo.com>
Newsgroups: local.lists.zope.zope-cmf
To: <zope-cmf@zope.org>
Sent: Friday, February 21, 2003 3:18 PM
Subject: Re: [Zope-CMF] Extending a Plone Object


> Raphael Ritz  <r.ritz@biologie.hu-berlin.de> wrote:
> > >I would like to create a new content type by adding a new field
(summary) to
> > >the standard Event object. And then create new forms based on the
standard
> > >event forms with the new field on it.
> >
> > Unfortunately you can't extend existing content types by simply adding a
> > few more
> > properties (I wish there were an easy way for this).
>
> 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.
>
> Florent
> --
> Florent Guillaume, Nuxeo (Paris, France)
> +33 1 40 33 79 87  http://nuxeo.com  mailto:fg@nuxeo.com
>
> _______________________________________________
> Zope-CMF maillist  -  Zope-CMF@zope.org
> http://mail.zope.org/mailman/listinfo/zope-cmf
>
> See http://collector.zope.org/CMF for bug reports and feature requests
>
>