getting contents of file into a variable
How can I do this? I try this way: <dtml-let shovedid="SEMESTERID_HOVED" hovedid="str2int(shovedid)"> where SEMESTERID_HOVED contains one line of integers (20021). str2int is an external python script just returning the int-cast of whatever string it gets in. Traceback (innermost last): File /export/space/Zope/Zope-2.4.x/lib/python/ZPublisher/Publish.py, line 223, in publish_module File /export/space/Zope/Zope-2.4.x/lib/python/ZPublisher/Publish.py, line 187, in publish File /space/Zope/Zope-2.4.x/lib/python/Zope/__init__.py, line 226, in zpublisher_exception_hook (Object: fag) File /export/space/Zope/Zope-2.4.x/lib/python/ZPublisher/Publish.py, line 171, in publish File /space/Zope/Zope-2.4.x/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: lagKataloger_ogOppdater) File /export/space/Zope/Zope-2.4.x/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: lagKataloger_ogOppdater) File /export/space/Zope/Zope-2.4.x/lib/python/OFS/DTMLMethod.py, line 200, in __call__ (Object: lagKataloger_ogOppdater) File /space/Zope/Zope-2.4.x/lib/python/DocumentTemplate/DT_String.py, line 546, in __call__ (Object: lagKataloger_ogOppdater) File /export/space/Zope/Zope-2.4.x/lib/python/DocumentTemplate/DT_In.py, line 770, in renderwob (Object: finnalt) File /export/space/Zope/Zope-2.4.x/lib/python/DocumentTemplate/DT_With.py, line 148, in render (Object: _.getitem(kodeaar(aarid),1)) File /export/space/Zope/Zope-2.4.x/lib/python/DocumentTemplate/DT_With.py, line 148, in render (Object: _.getitem(kode,1)) File /export/space/Zope/Zope-2.4.x/lib/python/DocumentTemplate/DT_Let.py, line 147, in render (Object: shovedid="SEMESTERID_HOVED" hovedid="str2int(shovedid)") File /export/space/Zope/Zope-2.4.x/lib/python/DocumentTemplate/DT_Util.py, line 231, in eval (Object: str2int(shovedid)) (Info: shovedid) File <string>, line 2, in f File /export/space/Zope/Zope-2.4.x/lib/python/Products/ExternalMethod/ExternalMethod.py, line 274, in __call__ (Object: str2int) (Info: ((<DTMLMethod instance at 16eed80>,), {}, None)) File /export/space/Zope/zope/Extensions/str2int.py, line 2, in str2int (Object: SEMESTERID_HOVED) AttributeError: (see above) As you can see, it gets the object not the string the object is containing. So how do I get the contents instead? regards Bjorge -- http://www.ii.uib.no/~bjorge/smile/Smiles -- Bjørge Solli - Universitas Bergensis, Norway mailto:Bjorge@Kvarteret.no icq#29210281 MSN:bobelloco@hotmail.com Møllendalsv.19, 5009 Bergen, Norway tel:+47 55202853/91614343
Bjørge Solli wrote:
How can I do this?
I try this way: <dtml-let shovedid="SEMESTERID_HOVED" hovedid="str2int(shovedid)"> where SEMESTERID_HOVED contains one line of integers (20021). str2int is an external python script just returning the int-cast of whatever string it gets in.
Hmm, without answering your original question ;-), why don't you use _.int(shovedid) ? cheers, oliver
You subject seems not to have anything to do with your problem report... =?ISO-8859-1?Q?Bj=F8rge_Solli?= writes:
I try this way: <dtml-let shovedid="SEMESTERID_HOVED" hovedid="str2int(shovedid)"> where SEMESTERID_HOVED contains one line of integers (20021). str2int is an external python script just returning the int-cast of whatever string it gets in.
Here you should have reported the "Error Type" and "Error Value", you see in the error report!
Traceback (innermost last): ...
231, in eval (Object: str2int(shovedid)) (Info: shovedid) File <string>, line 2, in f File /export/space/Zope/Zope-2.4.x/lib/python/Products/ExternalMethod/ExternalMethod.py, line 274, in __call__ (Object: str2int) (Info: ((<DTMLMethod instance at 16eed80>,), {}, None)) File /export/space/Zope/zope/Extensions/str2int.py, line 2, in str2int (Object: SEMESTERID_HOVED) AttributeError: (see above) You successfully called your External Method "str2int". In line 2 it tries to access an attribute which is not there. "Error Value" tells you its name...
Dieter
participants (3)
-
Bjørge Solli -
Dieter Maurer -
Oliver Bleutgen