Hi all, I have an External Method that parses a file and put the title, body, list of links, list of images into a dictionary. How do I now go about getting the info out of this dictionary? If I do a <dtml-var "filescript(REQUEST)"> it gives me the dictionary itself : {'title': 'Industrial Co-ordination Office', 'links': 'applications', 'index', 'partnershipweblinks', 'breakthroughs', 'pdf/applications.pdf', 'presentation', 'presentation', 'services', 'collaboration', 'workshop', 'documentation', 'techniques', 'techniques', 'pdf/techniques.pdf', , 'body':\r\n\r\n Beamlines\r\n\r\n (etc, etc), 'images': ['img/red.gif', 'img/indcodiv44.gif']} How do I get the value of each dictionary key back and how do I get rid of those horrible '\r\n\r\n". If I do a dtml-in it tells me that I cannot do a dtml-in with strings. TIA Marie Robichon Web Task Force European Synchrotron Radiation Facility BP 220 38043 Grenoble Cedex France http://www.esrf.fr Tel: (33) 04 76 88 21 86 Fax: (33) 04 76 88 24 27
Marie Robichon wrote:
Hi all,
I have an External Method that parses a file and put the title, body, list of links, list of images into a dictionary.
How do I now go about getting the info out of this dictionary?
If I do a <dtml-var "filescript(REQUEST)">
it gives me the dictionary itself :
{'title': 'Industrial Co-ordination Office', 'links': 'applications', 'index', 'partnershipweblinks', 'breakthroughs', 'pdf/applications.pdf', 'presentation', 'presentation', 'services', 'collaboration', 'workshop', 'documentation', 'techniques', 'techniques', 'pdf/techniques.pdf', , 'body':\r\n\r\n Beamlines\r\n\r\n (etc, etc), 'images': ['img/red.gif', 'img/indcodiv44.gif']}
How do I get the value of each dictionary key back and how do I get rid of those horrible '\r\n\r\n". If I do a dtml-in it tells me that I cannot do a dtml-in with strings.
hi, maybe something like this will do. simply replace the <dtml-let> with your dictionary: <dtml-let dict="{'title':'Dr.','name':'Jekill\r\n\r\n'}"> <dtml-in "dict.keys()" prefix=dc> <dtml-var dc_item>: <dtml-var "dict[dc_item].replace('\r\n','')"> </dtml-in> </dtml-let> -maik -- Maik Jablonski __o www.zfl.uni-bielefeld.de _ \<_ Deutsche Zope User Group Bielefeld, Germany (_)/(_) www.dzug.org
Marie Robichon wrote:
I have an External Method that parses a file and put the title, body, list of links, list of images into a dictionary.
How do I now go about getting the info out of this dictionary?
If I do a <dtml-var "filescript(REQUEST)">
try this: <dtml-with filescript mapping> <dtml-var title> <dtml-in links> <dtml-var sequence-item> </dtml-in> <dtml-war body> ...etc... </dtml-with> cheers, Chris
participants (3)
-
Chris Withers -
Maik Jablonski -
Marie Robichon