[Zope-CMF] [dev] RFC: Extensible propertysheet use cases

Michel Pelletier michel at dialnetwork.com
Thu Sep 30 13:53:58 EDT 2004


> Michel Pelletier wrote:
> > On Wed, 2004-09-29 at 13:40, yuppie wrote:
> >>Two reasons why I would prefer a new class:
> >>
> >>- The functions currently exposed in FactoryTypeInformation are
> mature 
> >>and fool save compared to the proposed PropertySheets machinery. If
> you 
> >>don't know exactly what you do, it is very likely that modifying the
> >>schema after creating instances of that type screws up your data.
> > 
> > 
> > The instance property sheets can define a custom getProperty that
> checks
> > against the type schema to see if it's changed.
> 
> And what happens if getProperty detects a schema change? It's easy to 
> change the schema in a way that's hard or even impossible to propagate
> without data loss.

No loss.  It works just like an instance whose Python class has
changed.  

If the instance has the property and the type doesn't (because it was
presumably removed), return the instance's property.  If the type has
the property and the instance doesn't, copy the type property's default
value to the instance and return it.

Again I'm a bit of a risk taker, so I might not be the best person to
make this decision, but I don't see this change really modifying any of
the underlying objects at all, types or their instances, because they
all already come with the property sheets mechanism ready to go.

Additionally this will not break any existing usage of property sheets
that I can think of, the only change WRT property sheets are the
instanciation semantics, sheets get copied when object are created or
accessed.  Existing objects and their pre-existing sheets are not
affected.

This just dawned on me, in fact this change does not require a new class
or any modification to the exsiting class at all, it just requires
replacing or providing an alternate 'invokeFactory'!  Call it
'invokeInstanceFactory'.  It does the sheet copying magic, creating
copies of property sheets on the instance that subclass fixed schema and
override getProperty to support schema changes.  No changes to the type
class at all.

Patches soon...

-Michel





More information about the Zope-CMF mailing list