[ZCM] [ZC] 197/ 1 Request "title property can be deleted"

Collector: Zope Bugs and Patches ... zope-coders@zope.org
Tue, 05 Feb 2002 17:40:07 -0500


Issue #197 Update (Request) "title property can be deleted"
 Status Pending, Zope/bug low
To followup, visit:
  http://collector.zope.org/Zope/197

==============================================================
= Request - Entry #1 by Anonymous User on Feb 5, 2002 5:40 pm

You call this python script from the current folder:

#Delete all existing properties
context.manage_delProperties(context.propertyIds())

You can then check the current folder "Properties" and indeed the title property is no longer listed.

However you can't add it again:
context.manage_addProperty('title', 'test property value', 'string')
return

This error results:

Error Type: Bad Request
Error Value: Invalid or duplicate property id

Dieter Maurer writes:

I can explain why this happens but fear there is no easy fix:

   In order to provide default values, a class attribute is defined for "title".

   When you delete the property, you delete it for the given object. Of course, other objects of the same type must keep their "title" and the default value (if they did not yet define title explicitly). Thus, the deletion must not touch the class attribute "title".

   In order to prevent a property addition to override existing names, it checks with "getattr(self,id)".
   This check sees the class's title attribute and refuses to create the property title.

And in a follow up I wrote:
 > If there is no fix then this command seems to be taboo:
 > context.manage_delProperties(context.propertyIds())

And Dieter responded:

`It's probably a (minor) Zope bug: "title" should be declared with mode "w" (which would prevent its deletion).'

Regards,
Adam Warner
==============================================================