[Zope] How to get the DTML code from a document/method?

Michel Pelletier michel@digicool.com
Thu, 8 Apr 1999 09:55:05 -0400


> -----Original Message-----
> From: Tony McDonald [mailto:tony.mcdonald@ncl.ac.uk]
> Sent: Thursday, April 08, 1999 7:46 AM
> To: Zope List
> Subject: RE: [Zope] How to get the DTML code from a document/method?
> 
> 
> I appreciate the feedback Rob, but 'there is one small problem...'
> 
> I still get the same traceback unfortunately.

> Ok, what dullard thing am I doing wrong?

I just tested this out, and appart from Rob's code being broken and
containing unreachable code it was close. :)

Here's my method:

import string

def view_source(self, path):
    id = string.split(path, "/")[-1]
    if not id: id = 'index_html'
    if not id in self.objectIds():
        id = 'index_html'
    doc = getattr(self, id)
    return doc.read_raw()
    

The DTML:


<!--#var standard_html_header-->
<H1>DTML Source for <!--#var path--></h1>

<pre>
<!--#var "view_source(path)" fmt="html-quote"-->
</pre>

<!--#var standard_html_footer-->


There is no 'documentIds'.  It would be pretty simple to add however.
This must be a holdover from Principia which was either removed or lost,
I think Rob is still running Principia on his DOS based 386. :)

-Michel

> ------
> Dr Tony McDonald,  FMCC, Networked Learning Environments Project
> The Medical School, Newcastle University Tel: +44 191 222 5888
> Fingerprint: 3450 876D FA41 B926 D3DD  F8C3 F2D0 C3B9 8B38 18A2
>