[Zope] How to get the DTML code from a document/method?
Tony McDonald
tony.mcdonald@ncl.ac.uk
Thu, 8 Apr 1999 08:52:01 +0100
>
>This is implemented as a Python External Method. I've pasted the source
>code below:
>
>Python source --> import string
>Python source -->
>Python source --> def view_source(self,path):
>Python source --> "view the source of a Document"
>Python source --> id=string.split(path,"/")[-1]
>Python source --> if not id: id="index_html"
>Python source --> if not id in self.documentIds():
>Python source --> id="index_html"
>Python source --> doc=getattr(self,id)
>Python source --> return doc.read_raw()
>Python source --> return id
>
>This gets called from a dtml_source document whose contents (strangely
>enough!) can be seen at:
>
>http://www.zope.org/dtml_source?path=/dtml_source
>
I'm doing something daft here - I keep getting
<!--
Error type:
Error value: read-only buffer, class
-->
.....
....
<!--
Traceback (innermost last):
File lib/python/ZPublisher/Publish.py, line 877, in publish_module
File lib/python/ZPublisher/Publish.py, line 590, in publish
(Info: /dtml_source)
File lib/python/OFS/DTMLDocument.py, line 212, in __call__
(Object: dtml_source)
File lib/python/OFS/DTMLDocument.py, line 208, in __call__
(Object: dtml_source)
File lib/python/DocumentTemplate/DT_String.py, line 513, in __call__
(Object: dtml_source)
File lib/python/DocumentTemplate/DT_Var.py, line 239, in render
(Object: view_source(path))
File lib/python/DocumentTemplate/DT_Util.py, line 266, in eval
(Object: view_source(path))
File <string>, line 0, in ?
File lib/python/Products/ExternalMethod/ExternalMethod.py, line
254, in __call__
(Object: CopySource)
(Info: (('index_html',), {}, None))
TypeError: (see above)
-->
(this was from trying /dtml_source?path=index_html but path='anything
else' gives the same error).
Is there a reason why there are two return statements in the external
method, when it seems that only the return doc.read_raw() is going to
be called?
tone
------
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