[PEAK] What's the right way to remove entries from an
EntityDM
Phillip J. Eby
pje at telecommunity.com
Fri May 20 18:03:41 EDT 2005
At 03:40 PM 5/20/2005 -0400, Erik Rose wrote:
>On Mar 21, 2005, at 11:28 AM, Phillip J. Eby wrote:
>>> From what i've seen in it's interface there's no mention on this
>>>subject, nor there is any in QueryDM. I've overritten __delitem__ so
>>>that it works as current __getitem__ does, by the oid.
>>
>>It's entirely up to you. I personally favor 'dm.remove(ob)', as to me
>>it's like removing an item from a list or set. peak.schema will use this
>>approach when it arrives, as it will treat a database as just a giant set
>>of objects. So 'db.add(ob)' and 'db.remove(ob)' will be used to add and
>>remove objects.
>
>Are you changing your mind, then, about the name of newItem() in EntityDM?
No. 'newItem()' and 'add()' are not synonyms; one creates a new instance
associated with a DM, the other adds an already-created instance to a database.
> I used delItem() in the code I'm working on for consistency with
> newItem(), but if you want to stick an add=newItem in EntityDM to
> canonicalize it, I'm all for it, as that would, as you intimated, be more
> Pythonic.
add=newItem won't work, because it doesn't do the same thing. It's
probably not a bad idea, however, to create an 'add' method, and perhaps a
stub 'remove' method. I'm just a bit reluctant to invest the effort,
versus working on peak.schema. However, if you'd like to write up a patch
(granting all rights, of course), I'll take a look at including it.
More information about the PEAK
mailing list