[Zope-CMF] Patch for more forward-compatible APB
Tres Seaver
tseaver@zope.com
18 Apr 2003 13:49:12 -0400
On Fri, 2003-04-18 at 13:05, Sidnei da Silva wrote:
> On Fri, Apr 18, 2003 at 12:04:15PM -0400, Tres Seaver wrote:
> | I don't mind the parts of the patch which surface the "readable" bits of
> | a dict; however, I don't think I want to encourage anybody to assume
> | that modifying the object through '__setitem__' / 'update' is
> | supported. Does Plone actually need that, or were you just being
> | thorough?
>
> For __setitem__ yes. There is some code in Plone and other products
> that does:
>
> actions = types_tool._cloneActions()
> for action in actions:
> if action['id'] == 'view':
> action['action'] = 'folder_listing'
> types_tool._actions = tuple(actions)
>
> (or something to that effect).
First, I presume that this code is actually manipulating the type
information objects' actions, rather than the tool actions; the tool
actions have not been dictionaries ever, I think. Second,
this is specifically the kind of usage I'd like to suppress: it is
subverting the TIs own handling of actions. I *especially* dislike the
last line there: it breaks encapsulation at least two ways (the name of
the attribute, plus its representation as a tuple).
If we *do* add your full patch, I would expect it to be immediately
deprecated: I don't want to introduce gratuitous breakage into Plone or
other projects, but I do want to discourage that kind of "monkey patch"
coding in the future.
> Notice that im restricting the values that can be read and set to a
> small set ( _props ), and that __setitem__ behaves differently for
> 'action', because it needs special treatment when being set.
>
> | > In the way, I also added a few __traceback_info__ to make debugging
> | > easier.
> |
> | Yep, no problem there.
> |
> | BTW, I vastly prefer to read unified diff. My ~/.cvsrc looks like:
> |
> | $ cat .cvsrc
> | -z7
> | diff -u
>
> Hey, nice tip!
Tres.
--
===============================================================
Tres Seaver tseaver@zope.com
Zope Corporation "Zope Dealers" http://www.zope.com