say youve got a structured-text file named 'textfile.txt' solution 1, dtml-only: <dtml-var "myLFS['textfile.txt'].data" fmt=structured-text> solution 2, pyscript and dtml: pyscript "test_py": ## Script (Python) "test_py" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters= ##title= ## lfs = context.lfs test_dtml = context.test_dtml f = lfs['textfile.txt'] data = f.data print test_dtml(client=context, REQUEST=context.REQUEST, data=data) return printed dtml method "test_dtml": <dtml-var data fmt=structured-text> you can replace the string 'textfile.txt' with a variable of course. cheers, peter. Elena Schulz wrote:
Dear List,
with the following PythonScript I try to render the content of txt-Files with LocalFS according to the howto of LocalFS (...snip..." To insert the text of the file after evaluating it as a DTML template in the current namespace, you would use: <dtml-var "test['foo.dtml'](_.None, _)"> .....snip ...").
My Script:
## Script (Python) "getContentFiles" ##bind container=container ##bind context=context ##bind namespace=_ ##bind script=script ##bind subpath=traverse_subpath ##parameters=REQUEST=None,myLFSInstance ##title=
myLFS = getattr(context, myLFSInstance) print myLFS['textfile.txt'](_.None,_)
but I get the below Error-Message. If I try:
print myLFS['textfile.txt'].data
the content is returned but without rendering (as expected). Does anybody know how to get the rendering done?
Thanks a lot for your help,
Elena
Error-Message:
Error Type: AttributeError Error Value: __call__:
Traceback (innermost last): File J:\Zope\ZopeSite\lib\python\ZPublisher\Publish.py, line 223, in publish_module File J:\Zope\ZopeSite\lib\python\ZPublisher\Publish.py, line 187, in publish File J:\Zope\ZopeSite\lib\python\Zope\__init__.py, line 226, in zpublisher_exception_hook (Object: jobs) File J:\Zope\ZopeSite\lib\python\ZPublisher\Publish.py, line 171, in publish File J:\Zope\ZopeSite\lib\python\ZPublisher\mapply.py, line 160, in mapply (Object: index.html) File J:\Zope\ZopeSite\lib\python\ZPublisher\Publish.py, line 112, in call_object (Object: index.html) File J:\Zope\ZopeSite\lib\python\OFS\DTMLMethod.py, line 199, in __call__ (Object: index.html) File J:\Zope\ZopeSite\lib\python\DocumentTemplate\DT_String.py, line 546, in __call__ (Object: index.html) File J:\Zope\ZopeSite\lib\python\OFS\DTMLMethod.py, line 192, in __call__ (Object: inhalt) File J:\Zope\ZopeSite\lib\python\DocumentTemplate\DT_String.py, line 546, in __call__ (Object: inhalt) File J:\Zope\ZopeSite\lib\python\DocumentTemplate\DT_Util.py, line 231, in eval (Object: getContentFiles(_.None,sourceFolder,contentFiles)) (Info: getContentFiles) File <string>, line 2, in f (Object: guarded_getattr) File J:\Zope\ZopeSite\lib\python\Shared\DC\Scripts\Bindings.py, line 324, in __call__ (Object: getContentFiles) File J:\Zope\ZopeSite\lib\python\Shared\DC\Scripts\Bindings.py, line 354, in _bindAndExec (Object: getContentFiles) File J:\Zope\ZopeSite\lib\python\Products\PythonScripts\PythonScript.py, line 363, in _exec (Object: getContentFiles) (Info: ({'script': <PythonScript instance at 01F468C0>, 'context': <Folder instance at 01F4D430>, 'container': <Folder instance at 01EF0530>, '_': <TemplateDict object at 01EB1A30>, 'traverse_subpath': []}, (None, 'stxTexte', ['jobs.txt']), {}, (None, None))) File Script (Python), line 16, in getContentFiles AttributeError: (see above)
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )