Recursive <dtml-var> statements
This is not the first time I've had to try and hack around Zope not letting me recurse <dtml-var> statements, but this is the first time that I haven't found a solution. My hair is turning greyer by the minute. Here's an example of what I'm trying to do: arguments: target_field:string old_value_list:list old_value:string new_value:string And the function replace() just does string.join(string.split(input, old_value), new_value). <dtml-in old_value_list> update table_name set <dtml-var target_field>= '<dtml-var "replace(sequence-item, old_value, new_value)" sql_quote>' where <dtml-var target_field>='<dtml-var sequence-item sql_quote>' <dtml-var sql_delimiter> </dtml-in> This would, if it ever works, generate statements like the following: update table_name set url='www.foo.org' where url='www.foo.com'; update table_name set url='www.bar.org' where url='www.bar.com'; update table_name set url='www.baz.org' where url='www.baz.org'; ...if I was generating update statements to replace .com with .org for certain values of title_field. All of my external methods and what-have-you are defined and accessible. I originally started out with the full string.join(string.split) hooplah instead of the function replace(), but this is where things currently stand. My problem? I can't access sequence-item within another dtml-var statement. This would not be an issue if I didn't have to modify the contents of old_value_list within the dtml-in statement. Accessing it directly via <dtml-var sequence-item> works perfectly fine, of course, but I can't just stick that within another dtml-var. If I could do this: <dtml-var "replace(<dtml-var sequence-item>, old_value, new_value)"> ...my life would be easy. I have tried representing sequence-item within the dtml-var in (at least) the following additional ways: _.REQUEST(['sequence-item']) _['sequence-item'] _.getitem(sequence-item) I originally had this whole mess shipped off to an external method, which worked just fine until the input list generated a return string longer than the max query length (16382ish), even though the return string was separated into single update requests as I described above. The whole reason I'm doing this within Zope is to get the <dtml-var sql_delimiter> tag on my side. Suggestions are very, very welcome. Please include a CC: to my e-mail address with any replies, since I am not subscribed to the mailing list. Thank you very much, --Kyle UCSC University Library
participants (1)
-
Kyle D. Lanclos