[Zope] StructuredText & LocalFS in Python Script
Jim Penny
jpenny@universal-fasteners.com
Fri, 2 Aug 2002 11:06:27 -0400
On Fri, Aug 02, 2002 at 09:49:21AM +0200, Elena Schulz wrote:
> Dear List,
>
> having the following objects:
>
> sourceFolder points to a LocalFS-Instance,
> fileId points to a file in the LocalFS-Instance,
> and convert_nonascii_1(string) is just a method to exchange some text in
> string.
>
> in DTML I can do the following:
>
> <dtml-var "convert_nonascii_1(_.str(_.getitem(sourceFolder, 1)[fileId]))"
> fmt=structured-text>
>
> But how is it done in Python Script?
>
> if myLFSname is the name of the LocalFS-Instance and file.txt the name of a
> file in the LocalFS-Instance this works fine:
>
> context.myLFSname['file.txt']()
>
> But as soon as I try to do it with sourceFolder and fileId, I get only
> errors even if the Script can resolve both.
> Does anybody know why?
Sorry, my head hurts thinking about this!
> And how do I use structured Text in Python Script as
> in DTML:
> <dtml-var my Var fmt=structured-text>
>
> Thanks a lot for your help,
>
> Elena
>
I define a pythonscript stx_ps with parameter text and body
from Products.PythonScripts.standard import structured_text
if not text:
return ''
return structured_text(text)
The only reason for the extra method is the guard. stx gets upset if
passed an empty string.
Jim Penny
>
>
>
>
>
>
> _______________________________________________
> 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 )
>