Nitesh Dhanjani writes:
 > 
 > Hello,
 > 
 > I have a Z SQL method which returns me a string like {{"a"},{"b"},{"c"}}
 > 
 > Is there anyway I can write a dtml-in loop to pick out each element from
 > the string? I want to be able to do something like:
 > 
 > <dtml-in my_zsql_method_which_returns_a_string>
 > <dtml-var element>,
 > </dtml-in>
 > 
 > and that should give me "a,b,c".
You are sure, the string always has this format?

Then there is a solution, though an external method might be better:

        <dtml-let result=sql_method
                  strip_outer_chars="result[3:-3]"
                  split="_.string.split(strip_outer_chars,'\x22},{\x22')"
                  rejoin="_.string.join(split,',')"
        >
          <dtml-var rejoin> <!-- your a,b,c -->
        </dtml-let>


Dieter

_______________________________________________
Zope maillist  -  [EMAIL PROTECTED]
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 )

Reply via email to