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

Zope@Stylus zope@stylusinc.net
Wed, 21 May 2003 13:46:54 +0530


Hi all,
Could someone please help me out here.
I am trying to use manage_clone to clone python scripts and Page Templates
into a newly added folder into the Zope Directory Structure everytime I add
a folder into the Zope Directory Structure
If not manage_clone what other function can i use to dynamically add Python
Scripts and Page Templtes to my newly created folder , like creating a
microsite for registered members.
For every registered member I want to create a microsite with his own set of
file in it.
But I am not being able to do it
Using manage_clone in a Python file and adding it as an external method does
not work as it is asking the user to Login to the ZMI.Then the whole point
of my site is gone.
I wanted to add a new folder for a registered memebr when he  registers and
create a minumum number of files in the folder which will give him
functionality.
This is excactly similar to what Zope does when adding a Folder Object.You
can also dynamically add an index_html Page into it.
Exactly simliar is my need..to add a folder for a new user and then add 2
python scripts and two page templates into the newly added folder.
The maange_clone function requires a user to be logged in to the ZMI.
Please help me out here.
Thanks once again and Best regards
John

: Hi Phil ,
:
: 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: "Phil Harris" <phil.harris@zope.co.uk>
: To: <zope@zope.org>
: Sent: Monday, May 19, 2003 6:44 PM
: Subject: Re: [zope] [Zope] How to Add a File Dynamically??
:
:
: : You can use manageClone to do exactly this, example code, assuming this
is
: : in a python script:
: :
: : context.manage_clone(someobject,'new id to create in this place')
: :
: : context can of course be replaced with any folderish object, so:
: :
: :
: : somefolder.manage_clone(someobject,'new id to create in this place')
: :
: : works in the same way
: :
: : hth
: :
: : Phil
: :
: : On Mon, 19 May 2003 17:58:33 +0530, Zope@Stylus <zope@stylusinc.net>
: wrote:
: :
: : > Hi
: : >
: : > I am working on Zope-2.5.1 installed on Mandrake Linux 9.0. I am
working
: : > currently on a small project that functions similar to the CMF but not
: : > completely covering all its features.
: : > I am basically  trying to add a folder into the Zope Directory
Structure
: : > and
: : > then trying to upload files into the newly added folder through my web
: : > interface (Not ZMI)
: : >
: : > 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)
: : >
: : > My Backend is Postgresql 7.2.2. For adding Folders and Files intot the
: : > Zope
: : > Directory I am using External Methods which are functioning perfectly
: : > fine.
: : > But the main issue is that when I add a folder I want that  three
: objects
: : > are added into the folder as well by default.
: : > a Python Script
: : > a Page Tenplate
: : > a ZSQL Method
: : > These three Objects should contain the code which is decided by me and
: is
: : > a
: : > constant in all folders like the code in index_html for all folders.
: : > The Zope folder Object accomplishes this ... when we add a folder if I
: : > select to add a User Interface .. a default page template is added
: called
: : > index_html.
: : >
: : > I also would like to do something exactly similar.Please help me out
...
: : > I m
: : > stuck with this for quite a few days now.
: : > Thanks for reading through the whole letter .. n thanks in advance for
: : > all
: : > Help.
: : >
: : > Best Regards
: : > John
: : >
: : >
: : >
: : >
: : > ---
: : > Outgoing mail is certified Virus Free.
: : > Checked by AVG anti-virus system (http://www.grisoft.com).
: : > Version: 6.0.481 / Virus Database: 277 - Release Date: 5/13/2003
: : >
: : >
: : > _______________________________________________
: : > Zope maillist  -  Zope@zope.org
: : > http://mail.zope.org/mailman/listinfo/zope
: : > **   No cross posts or HTML encoding!  **
: : > (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
: : > http://mail.zope.org/mailman/listinfo/zope-dev )
: : >
: : >
: :
: :
: :
: : --
: : Phil Harris
: :
: : _______________________________________________
: : Zope maillist  -  Zope@zope.org
: : http://mail.zope.org/mailman/listinfo/zope
: : **   No cross posts or HTML encoding!  **
: : (Related lists -
: :  http://mail.zope.org/mailman/listinfo/zope-announce
: :  http://mail.zope.org/mailman/listinfo/zope-dev )
: :
: :
:
:
: ---
: 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
:
:
: _______________________________________________
: Zope maillist  -  Zope@zope.org
: http://mail.zope.org/mailman/listinfo/zope
: **   No cross posts or HTML encoding!  **
: (Related lists -
:  http://mail.zope.org/mailman/listinfo/zope-announce
:  http://mail.zope.org/mailman/listinfo/zope-dev )
:
:


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