[Zope-dev] adding properties to instances v. classes
Jamie Heilman
jamie@audible.transient.net
Thu, 21 Nov 2002 07:22:58 -0800
There's this somewhat annoying issues surrounding objects that declare
removable properties in their classes, in that if you remove them, you
can't add them again because many times a class variable of the same
name already exists. (atleast thats my understanding of it, I suppose
I could be smoking something) The issue was raised in bug 337 which
was subsequently closed after the Image class got a slight massaging.
I'm wondering if there's any reason why simply adding the properties
and instance variables to the instance within __init__ would be a bad
thing for properties that you want to declare removable. For example:
class Baz(Stuff):
"""meh."""
title = ''
_properties = ({'id':'title', 'type': 'string', 'mode':'w'},)
def __init__(self, id, title, foo):
self._properties += ({'id':'foo', 'type':'string'},)
self.foo = foo
self.title = title
...
Seems like it would be a fairly easy fix and it certainly seems to
work, am I missing something?
I'm also wondering what the deal is with the title property, should it
alway be removable, always be unremovable, or always be what you want
it to be depending on your mood ring? It doesn't seem like there's a
great deal of consistency and I'm wondering if thats intentional.
--
Jamie Heilman http://audible.transient.net/~jamie/
"It's almost impossible to overestimate the unimportance of most things."
-John Logue