[Zope-dev] manage_addDTMLMethod/Document taking contents as argument?

Anthony Baxter anthony@interlink.com.au
Tue, 09 Nov 1999 13:57:30 +1100


Is there any reason why manage_addDTMLMethod/Document doesn't accept the 
new contents as anything other than a file object?

Is something like the following acceptable?

- def addDTMLDocument(self, id, title='', file='', REQUEST=None, submit=None):
+ def addDTMLDocument(self, id, title='', file='', data=None, REQUEST=None, 
+                                                               submit=None):
      """Add a DTML Document object with the contents of file. If
      'file' is empty, default document text is used.
      """
      if type(file) is not type(''): file=file.read()
-     if not file: file=default_dd_html
+     if not file: 
+         if data is not None:
+             file=data
+         else:
+             file=default_dd_html
      ob=DTMLDocument(file, __name__=id)
      ob.title=title
      id=self._setObject(id, ob)
      if REQUEST is not None:
          try: u=self.DestinationURL()
          except: u=REQUEST['URL1']
          if submit==" Add and Edit ": u="%s/%s" % (u,quote(id))
          REQUEST.RESPONSE.redirect(u+'/manage_main')
      return ''