[Zope-CMF] How to save extra data with CMF-object
Tres Seaver
tseaver@palladion.com
Thu, 12 Jul 2001 16:18:10 -0400 (EDT)
On Thu, 12 Jul 2001, Robert Rottermann wrote:
> Hi there,
> what would be the best way to save extra data with a CMF object.
> I would like to have my own type created with the portal_types tool. Next to
> the standard metadata I would like to save some extra information.
> Do I have to "misuse" one of the standard metadata fields I do not need, or
> is there an other way to go.
I was about to say "make a ZClass", when it occurred to me to
check something out::
>>> import Zope
>>> app = Zope.app()
>>> doc = app.cmf.Members.tres.index_html
>>> doc.manage_addProperty( 'foo', 'bar', 'string' )
>>> doc.propertyMap()
({'id': 'title', 'mode': 'w', 'type': 'string'}, {'id': 'foo', 'type': 'string'})
>>> doc.foo
'bar'
AIYAH!
It turns out that CMFDefault.DefaultDublinCoreImpl derives
(for unknown reasons) from PropertyManager; therefore, virtually
all content objects can have custom properties added to them!
As to whether this is a Good Thing (tm), I am of a divided mind.
I can't see any reason that DDCI *needs* to have such a base
class, but it does make "quick-and-dirty" custom schema simple.
Tres.
--
===============================================================
Tres Seaver tseaver@digicool.com
Digital Creations "Zope Dealers" http://www.zope.org