[Zope] Adding content to document types
   
    J Cameron Cooper
     
    jccooper@jcameroncooper.com
       
    Wed, 05 Mar 2003 13:31:20 -0600
    
    
  
>
>
>I'm adding documents & scripts to a folder using -
>    context.manage_addDTMLMethod("index_html", "Index") #document name &
>title
>etc.
>
>These documents are created with default body content.
>
>My question is - how do I access/add to/replace the content that is inserted
>into the documents by default? For example, I'd like to insert dynamically
>generated code into Python scripts, or into the DTML document using
>properties defined within the folder.
>  
>
The manage_addXXX methods generally have a parameter that you can set 
for content (although this is not always shown in the generated API docs.)
For DTMLMethods, for instance, you can see in the source 
(lib/python/OFS/DTMLMethod.py) a function definition
def addDTMLMethod(self, id, title='', file='', REQUEST=None, submit=None):
    """Add a DTML Method object with the contents of file. If
    'file' is empty, default document text is used.
    """
which is used as 'manage_addDTMLMethod()' (this is defined in some 
__init__.py). So if you say
data = "I am the new content. Woo hoo."
context.manage_addDTMLMethod("index_html", "Index", data) # document 
name & title
you will create an index_html titled "Index" with the content "I am the 
new content. Woo hoo."
          --jcc