[Zope] StructuredText & LocalFS in Python Script
peter sabaini
sabaini@inode.at
Fri, 02 Aug 2002 10:08:35 +0200
it seems sourceFolder holds the id of your LFS instance, ie. its a
string, right?
you get the LFS instance with getattr(), for example:
myLFS = getattr(context, sourceFolder)
return myLFS[fileId]() # or whatever it is you want to do with the LFS
i'd stick with DTML to output structured text -- just pass the return
value of the pyscript above to DTML, sth like: <dtml-var pyScript
fmt=structured-text>
hth
peter.
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? 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
>
>
>
>
>
>
>
> _______________________________________________
> 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 )
>
>