I have trivial class: <file MyClass.py>: from OFS import SimpleItem from Globals import DTMLFile def manage_addMyClass(self, id, REQUEST): "add" a=MyClass(id) self._setObject(id,a) if REQUEST: return self.manage_main(self, REQUEST) manage_addMyClassForm=DTMLFile('dtml\manage_addMyClassForm',globals()) class MyClass(SimpleItem.SimpleItem): "minimal object" meta_type='MyClass' def __init__(self, id): "init" self.id=id I can add objects of MyClass through ZMI. How can I add some object through my own interface: for example, on button click on DTML form? Regards, Serg.
(please stop posting in html) Serg wrote:
I can add objects of MyClass through ZMI. How can I add some object through my own interface: for example, on button click on DTML form?
Have that form submit to a python script and do something like: context.manage_addProduct['Your Product Name'].manage_addMyClass(id,None) cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
I can add objects of MyClass through ZMI. How can I add some object through my own interface: for example, on button click on DTML form?
Have that form submit to a python script and do something like: context.manage_addProduct['Your Product Name'].manage_addMyClass(id,None) cheers, Chris
How can I determine 'My Product Name'? My class named 'MyClass'. It be located in dir ../Python/Products/MyProject/. If I try use below context.manage_addProduct['MyClass'].manage_addMyClass(id,None) Zope write: "An error was encountered while publishing this resource. Error Type: AttributeError Error Value: MyClass" Thanks and kind regards Serg
Serg wrote:
How can I determine 'My Product Name'? My class named 'MyClass'. It be located in dir ../Python/Products/MyProject/.
the html source on a page in the Zope management interface where objects are added, will show you how to do it. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science
Hi Serg, Serg wrote:
I can add objects of MyClass through ZMI. How can I add some object through my own interface: for example, on button click on DTML form?
Have that form submit to a python script and do something like: context.manage_addProduct['Your Product Name'].manage_addMyClass(id,None) cheers, Chris
How can I determine 'My Product Name'? My class named 'MyClass'. It be located in dir ../Python/Products/MyProject/.
If I try use below context.manage_addProduct['MyClass'].manage_addMyClass(id,None)
Zope write: "An error was encountered while publishing this resource. Error Type: AttributeError Error Value: MyClass"
If your product is correctly initialized, context.manage_addProduct['MyProject'].manage_addMyClass(id,None) should work. Regards Tino Wildenhain
Serg wrote:
How can I determine 'My Product Name'? My class named 'MyClass'. It be located in dir ../Python/Products/MyProject/.
Generally it'll be "MyProject" then, if you want to implement something like the Add menu in the ZMI, look at /lib/python/OFS/dtml/mail.dtml for the bit with the comment <!-- Add object widget -->. filtered_meta_types is your friend.
If I try use below context.manage_addProduct['MyClass'].manage_addMyClass(id,None)
Zope write: "An error was encountered while publishing this resource. Error Type: AttributeError Error Value: MyClass"
Try: context.manage_addProduct['MyProject'].manage_addMyClass(id,None) cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
participants (5)
-
Chris Withers -
Max M -
Serg -
Serg -
Tino Wildenhain