ZPT : return a string HTML from a script python

Bernard Yue bernie at 3captus.com
Fri Apr 5 22:58:33 EST 2002


Marco wrote:
> 
> I have a ZPT and I want to print an HTML string (it's arrive from a
> script python) inside it.
> 
> This is a piece of ZPT code that call the script "pyPrint"
> 
> --   <span tal:content="python:here.pyPrint
> --        (folder=request['folder3'])">
> --   </span>
> 

Use 'structure' to render the return.

    <span tal:content="structure python:here.pyPrint
        (folder=request['folder3'])">
    </span>

You can find more example on
http://www.zope.org/Members/peterbe/DTML2ZPT.


> This is a script
> 
> --  message = "Result: <br>"
> --  for folder in folder:
> --      folder=container.pyString2list(string=folder.id)
> --      rootFolder = container.restrictedTraverse(['',]) # container
> --      folderDaCancellare = rootFolder
> --      folderPadre = None
> --      for item in folder[1:]:
> --          folderPadre = folderDaCancellare
> --          folderDaCancellare = folderDaCancellare[item]
> --      message = messaggio+folderDaCancellare.id
> --      if folderPadre != None and
> len(folderDaCancellare.objectValues()) == 0:
> --          folderPadre.manage_delObjects(folderDaCancellare.id)
> --          message = message + " cancellato<br>"
> --      else:
> --          messaggio = message + " non cancellato<br>"
> --
> --  return message
> 
> I want that the <br> tag will become a new line in ZPT page.
> 
> Sorry for my english

-- 
One OS to rule them all, one OS to find them,
One OS to bring them all and in the darkness bind them,
In the Land of Redmond, where the Shadows lie.



More information about the Python-list mailing list