[Grok-dev] Dolmen and its releases
Martin Aspeli
optilude+lists at gmail.com
Thu Oct 22 11:22:10 EDT 2009
Souheil CHELFOUH wrote:
> This is one thing. The most interesting part is that we effectively
> respect the interface, providing the default, respecting the readonly,
> etc.
> For the __parent__ thing, i need to work on it more closely. I'll
> probably return a containment proxy instead.
Just a couple of suggestions from someone who's recently been working on
very similar things (plone.namedfile, plone.app.textfield):
- avoid proxies if you can; they cause confusion and another layer of
indirection
- if you need a proxy, there's the one from zope.location
- ask yourself why it needs to know the __parent__ - avoid if you can
- setting immutable 'value' object is better than having a mutable
value object. You almost never need to change it, and making them
mutable means you have to worry about persistence
- a 'value' object probably shouldn't derive from Persistent, since it
means you're getting a new ZODB p_jar for each one in addition to the
parent object; you want to be in the same jar as the parent most of the
time (or in a blob)
- field properties that do readonly, default (mmm, you probably want
missing_value) etc sound neat, but are less useful in practice. There's
FieldProperties in the ZTK of course that basically do most of what you
are doing except the __praent__ thing
Martin
--
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book
More information about the Grok-dev
mailing list