[Zope] "dtml_source"

Piers Lauder piers@cs.su.oz.au
Sat, 10 Apr 1999 14:38:13 +1000


Someone posted an External Method to display DTML Document source recently.
I've modified it to interpret paths, so now one can say:
	http://www.zope.org/dtml_source?path=/x/y/z
and it will show the source of z, an object inside y, which is an object inside x.
And so on. Maybe there's a reason the original didn't do this?

Anyway, here's my version of Extensions/dtml_source.py :-

import string
def view_source(self, path):
        "View the source of a Document"
        for id in string.split(path, '/'):
                if not id:
                        continue        # Leading /
                if id not in self.objectIds():
                        id = None
                        break
		# Walk down object hierarchy
                self = getattr(self, id)
        if not id:
                self = getattr(self, 'index_html')
        return self.read_raw()