[Zope-dev] manage_addDTMLMethod/Document taking contents as a
rgument?
Brian Lloyd
Brian@digicool.com
Tue, 9 Nov 1999 10:38:37 -0500
> 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)
> ...
Actually, file may be either a file object *or* a string -
you should just be able to do:
self.addDTMLDocument('MyDoc', title='MyTitle', file='my data...')
Brian Lloyd brian@digicool.com
Software Engineer 540.371.6909
Digital Creations http://www.digicool.com