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

Gilles.Lavaux gilles.lavaux@esrin.esa.it
Thu, 8 Apr 1999 10:46:27 +0200


Tony McDonald wrote:
>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
cut
>I'm doing something daft here - I keep getting
><!--
> Error type:
> Error value: read-only buffer, class
> etc...




Hello

I had the same error with this code, so I got rid of  the path stuff and
pass directly the document id:
def view_source(self,id):
    doc=getattr(self,id)
    return doc.read_raw()

At least it works for me.If someone has a better solution, please post it...

Gilles