Adding Folders and index_html from Python Script
Okay, I'm trying to create a site where the users can load information about prospective clients and then add contact information about each client. This is how it works now... I have a form that creates a folder with the name of the client as the title of the folder. No sweat. I use... context.manage_addProduct['OFSP'].manage_addFolder(id=id, title=clientName) .. which works fine to make the folder itself. However, there is nothing in the folder (i.e., no index_html file). Thus, when the user moves to the folder, they get the index_html from the parent folder. Is there a way to add a file to the newly created folder from a Python script? The contents of the file can be very easy (such as "<dtml-var standard_html_header><dtml-var standard_html_footer>"). As an asisde, I want to make the id of the folder a string that contains only allowable characters that are taken from the name that the users input (with an _ used in place of the blanks). Is there a quick easy way to do that with some library function that isn't showing up in the Python Library Reference at www.python.org? Thanks in advance, Ron
Hi, Check out the source for manage_addFolder and you will find that you can specify 2 additional options or flags. They are for creation of user folders and the index_html template file. Just call the function with these 2 flags set and you get the acl_users and the index_html template in your folder. Cheers, A.R.K
Okay, I'm trying to create a site where the users can load information about prospective clients and then add contact information about each client. This is how it works now...
I have a form that creates a folder with the name of the client as the title of the folder. No sweat. I use...
context.manage_addProduct['OFSP'].manage_addFolder(id=id, title=clientName)
.. which works fine to make the folder itself.
However, there is nothing in the folder (i.e., no index_html file). Thus, when the user moves to the folder, they get the index_html from the parent folder.
Is there a way to add a file to the newly created folder from a Python script? The contents of the file can be very easy (such as "<dtml-var standard_html_header><dtml-var standard_html_footer>").
As an asisde, I want to make the id of the folder a string that contains only allowable characters that are taken from the name that the users input (with an _ used in place of the blanks). Is there a quick easy way to do that with some library function that isn't showing up in the Python Library Reference at www.python.org?
Thanks in advance,
Ron
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
-- Windows Sucks!!Linux Rules!!!.
complaw@hal-pc.org wrote:
As an asisde, I want to make the id of the folder a string that contains only allowable characters that are taken from the name that the users input (with an _ used in place of the blanks). Is there a quick easy way to do that with some library function that isn't showing up in the Python Library Reference at www.python.org?
Because I only worry about spaces in this situation, I use: <dtml-call "REQUEST.set('id', _.string.capitalize(_.string.replace(med_name,' ', '_')))"> (Yes I know I shouldn't do this in DTML, but I didn't know better when I wrote it. <s>) To convert all non-legal characters you would need to use "maketrans". You should be able to find it in any good Python reference. HTH, -- Tim Cook, President - FreePM,Inc. http://www.FreePM.com Office: (901) 884-4126 ONLINE DEMO: http://www.freepm.org:8080/FreePM
participants (3)
-
complaw@hal-pc.org -
karthick ramanarayanan -
Tim Cook