[Zope] DTML script (or python method) to change the object type of

Kapil Thangavelu kthangavelu@earthlink.net
Thu, 10 Aug 2000 07:33:53 -0700


Lucas Hofman wrote:
> 
> Could anybody point me in the right direction regarding making a script
> that converts all DTML Documents is a directory tree to DTML Methods?
> 
> Thanks,

code up an external method - here is some sample pseudo code(looks like
python buts its not:). this one sits in the folder to be converted. you
might need to work on getting hold of the folder object, aq_parent or
the like. 

def Doc2Method(self, REQUEST=None):
	docs = self.objectItems(['DTML Document'])"
	for key, item in docs:
		text =item.read_raw() # read the raw source
		self.delObjects(key) # delete the document
		self.manage_addDTMLMethod(key) # add the dtml method
		self.getattr(key).manage_Change(text) # add code				
	
	return 'Done'

you probably want to look at the ZQR or better the python source to
DTMLDocument and DTMLMethod for the exact syntax and method names. Be
careful about not being in a transaction and losing the doc if you bomb
in the middle. you should still be able to undo through it the undo tab.


Cheers

Kapil