Anyone know how to add a property to a Zope Product (not its instances)?
I am developing a new Zope product in python. Normally one adds properties to a product like so: class newProduct(SimpleItem, etc): meta_type 'NewProduct' _properties = ( {'id': 'title', 'type':'string'}, { 'id':'description', 'type':'string'}, {'id':'foobar' , 'type':'string'"}, ) . . . This defines properties for instances of the new Product. But I want to add properties for the product itself. These properties would show up in the property sheet of the PRODUCT, not its instances-- ie in Root Folder/Control_Panel/Products/NewProduct on the Properties tab. By default, Zope adds the title and version properties, for which it gets the value from version.txt and meta_type, but does anyone know a way to add more? Thanks in advance, --Craeg
By default, Zope adds the title and version properties, for which it gets the value from version.txt and meta_type, but does anyone know a way to add more?
This is only half an answer, but maybe it helps: I am not quite sure if you can do that the easy way from Python. (I.e. just define a _properties list). But you certainly can use manage_addProperty: self.Control_Panel.Products.YOURPRODUCT.manage_addProperty(id="TEST", value="TEST ENTRY", type="string") The question is where to put this, probably somewhere in the __init__.py? I don't know if you CAN call it from there. It definitely works from the contructor method of your product, but then the new property will only show up after the first instance has been added ... Joachim
On Saturday 20 October 2001 05:41 pm, Joachim Werner allegedly wrote:
By default, Zope adds the title and version properties, for which it gets the value from version.txt and meta_type, but does anyone know a way to add more?
This is only half an answer, but maybe it helps:
I am not quite sure if you can do that the easy way from Python. (I.e. just define a _properties list). But you certainly can use manage_addProperty:
self.Control_Panel.Products.YOURPRODUCT.manage_addProperty(id="TEST", value="TEST ENTRY", type="string")
The question is where to put this, probably somewhere in the __init__.py? I don't know if you CAN call it from there. It definitely works from the contructor method of your product, but then the new property will only show up after the first instance has been added ...
Joachim
AFAIK Zope doesn't officially support meta-data associated with a product in any meaningful way. I have often thought this would be beneficial tho, as it would allow a product to have a global configuration interface in the ZMI that would affect all instances. I think it would be a worthwhile project to think about an API for product "preferences". Perhaps this could be added (as tabs I guess) to the exisitng Zope preferences. /---------------------------------------------------\ Casey Duncan, Sr. Web Developer National Legal Aid and Defender Association c.duncan@nlada.org \---------------------------------------------------/
participants (3)
-
Casey Duncan -
Craeg K. Strong -
Joachim Werner