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

Zope@Stylus zope@stylusinc.net
Tue, 20 May 2003 22:24:06 +0530


Hi Josef ,

Thanks for yopur prompt reply . I am tryiong to resolve my problem but
getting stuck again.Please help me out here.
I am trying to use manage_clone to add a python script into a folder .
I am adding a new folder intot the Zope directory Structure and then taking
the context of the newly added Flder and adding a Python Script into it
.This is similar to what Zope does when adding a folder and adding a Page
template(index_html) into it.
=============================================================
#My Python file which I am adding as an External Method in
Zope ---------obj_Clone_Sep.py
#from OFS import CopyContainer.manage_clone
from App.Common import *
import re
import CopyContainer
from Globals import REPLACEABLE, NOT_REPLACEABLE, UNIQUE
def getCloneSEP(folderObj,id,cloneObj,strName):
   ob=folderObj._getOb(id)  #getting the context of the folder
  if(strName != ''):
           ob.CopyContainer.manage_clone(cloneObj,strName) #I am cloning
cloneObj and giving it a new name
============================================================
#This is the Error I get on trying to add a Clone

Error Type: ImportError
Error Value: No module named CopyContainer
=============================================================
#My Python Script
#I first add a folder
#I then clone a Python Script into the Folder

  result =  context.sis.Public.add_fol_sep(context
,i=str(textname),tit=str(textname))
 #add_fol_sep is an External MEthod that ads a file into the current context
(which is a folder in the Zope Directory Structure)

 resu =
context.obj_Clone_Sep(context,id=str(textname),cloneObj=container.add_folder
_sep,strName='add_folder_sep')
#this is my call to External Python Script --------obj_Clone_Sep.py

return resu
============================================================================
=======
If  I try to add a Python file without importing the OFS Module I am asked
to login to the ZMI for accessing the manage_clone method .This is happening
inspite of my using External Methods.

Where am I going wrong??

Thanks and Best regards
John
----- Original Message -----
From: "Josef Meile" <jmeile@hotmail.com>
To: <zope@zope.org>
Sent: Monday, May 19, 2003 10:21 PM
Subject: [Zope] Re: How to Add a File Dynamically??


: > 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

:
:


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.483 / Virus Database: 279 - Release Date: 5/19/2003