[Zope] Re: How to Add a File Dynamically??

Josef Meile jmeile@hotmail.com
Mon, 19 May 2003 18:51:24 +0200


> While adding a new folder I would like to add 3 files by default into the
> folder (like when i add a folder object through ZMI)
> 1) index_html - (Page Template)
> 2) tree.py - (Python Script)
> 3) getPath.zsql - (ZSQL Method)
I did it for a DTMLMethod, but I think it is similar to the other cases. In
my case, I just created an external method with this:

from OFS import DTMLMethod

def createMethod(folderObj, id, title, text):
  # Creates a dtml Method
  DTMLMethod.addDTMLMethod(self=folderObj,id=id,title=title)
  #Gets a reference to the created object
  ob=folderObj._getOb(id)
  #Changes the contents of the created object
  ob.manage_edit(data=text,title=title)

You just have to look at the html source code of the Zope's manage
interface and see what methods are called when creating/editing a
python script, page template and a ZSQL Method. Then, you have
to search the implementation of this methods to see what parameters
you need and which packages you have to import.

Regards,
Josef