[Zope-CMF] Additional property to portal_type

Tres Seaver tseaver@zope.com
04 Aug 2002 09:26:42 -0400


On Sun, 2002-08-04 at 09:23, Jeffrey Franks wrote:
> Tres Seaver wrote:
> > 
> > On Thu, 2002-08-01 at 19:44, Pawel Lewicki wrote:
> > 
> > > Is there any simpler way to add an extra property to default CMFDocument
> > > (e.g.) than overriding the whole class?
> > 
> > ScriptableTypeInfo is your friend:
> > 
> > http://cmf.zope.org/Members/tseaver/how_tos/using_scriptable_type_info
> > 
> > You can add properties after creating the object using
> > 'manage_addProperty', e.g.::
> > 
> >   product.manage_addProperty( 'some_prop', 'initial value', 'string' )
> > 
> 
> I'm applying this to a portal_type of 'File' with meta_type 'Portal File'
> 
> I've added one attribute but can't view or edit it. I'm thinking that I
> need to create a new meta type and add view/edit scripts.
> 
> Is that what's needed?
> How can I get view and edit of these added attributes?

You will need to customize the skin methods (ZPT,Python Script,DTML)
which you use to render you objects.  For instance, if you have replaced
the "stock" File type with your own, then you would need to customize
the 'file_view' and 'file_edit_form' templates (ZPT in 'zpt_content'
skin diretory; DTML in 'content') and the 'file_edit' script (in
'content') to handle your new property.

If your extended file type does *not* replace the standard File, then
you probably want to create new skin methods for the view, edit form,
and edit script (starting from the File versions).

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