Getting data from object inside ZClass
I'm developing a product using ZClasses, and I'm having some problems. When I make an instance of my ZClass, I want to copy a number of DTMLDocuments that are contained inside the ZClass to the inside of the new ZClass instance. Here's what I've got: # add a new instance of the ZClass, initialize properties instance = container.DPPortal.createInObjectManager(request['id'], request) instance.propertysheets.Basic.manage_editProperties(request) # the ZClass producthome = getattr(container,'DPPortal') # make a new DTMLDocument with data from default_css source = getattr(producthome,'default_css') instance.manage_addDTMLMethod(id='designportal.css',title='Default Design Portal stylesheet',file=source.data)
Davis Marques wrote at 2003-8-22 17:45 -0700:
I'm developing a product using ZClasses, and I'm having some problems. When I make an instance of my ZClass, I want to copy a number of DTMLDocuments that are contained inside the ZClass to the inside of the new ZClass instance. Here's what I've got:
# add a new instance of the ZClass, initialize properties instance = container.DPPortal.createInObjectManager(request['id'], request) instance.propertysheets.Basic.manage_editProperties(request)
# the ZClass producthome = getattr(container,'DPPortal')
# make a new DTMLDocument with data from default_css source = getattr(producthome,'default_css') instance.manage_addDTMLMethod(id='designportal.css',title='Default Design Portal stylesheet',file=source.data)
This problem report is much better than the last one. But, it is still not optimal. You do not tell, what does not work, what exceptions you get (with traceback) if any. I expect, you get an "AttributeError" for "default_css". This is because (almost surely) "container" is the product and not the ZClass but you said above the DTMLDocuments to be copied where inside the ZClass. By the way, you must be very precise when you report problems. What is where and should go where is crucial for any useful response. When the objects to be copied are indeed inside the ZClass, it is easiest to access them via the instance (accessing them via the ZClass is very difficult). You can use "manage_clone" (from "OFS.CopySupport.CopyContainer) to do the copying. Dieter
participants (2)
-
Davis Marques -
Dieter Maurer