[Zope] DTML bug with database arrays in sqltest

Jonathan dev101 at magma.ca
Fri Jul 8 13:16:55 EDT 2005


You cannot embed one dtml tag within another dtml tag.

A couple of possible work-arounds:

1) use a python script to return the values you need
2) create a python script which 'builds' a new dtml script and then execute the new script (ugly, but it works - not very efficient, so how often you run this will be a factor).

hth

Jonathan

  ----- Original Message ----- 
  From: David Pratt 
  To: zope at zope.org 
  Sent: Friday, July 08, 2005 1:08 PM
  Subject: [Zope] DTML bug with database arrays in sqltest


  I am using arrays in Postgres. I need to be able to compare a string value in a specific position of a text array field (text[] is a field type in Postgres) against a variable(argument) I am passing to my query. I am only using parts of the query to illustrate the problem as the rest is irrelevant. I replaced the table, field names and arguments with names that might make this more understandable.

  First. I am finding arrays work fine with select statements in DTML when you use sqlvar to request a specific value from the array. 

  ie.

  SELECT
  a_table.an_array_field[<dtml-sqlvar some_value type="int">][2]
  FROM ....(rest of query)

  But when you put them inside a sqltest tag for evaluating values it throws an error because DTML cannot parse it.

  ie.

  SELECT ...
  blah blah.....
  <dtml-and>
  <dtml-sqltest column=a_table.an_array_field[<dtml-sqlvar an_array_key type="int">][2] name=a_title_var op="eq" type="string" optional>
  ..... (rest of query)

  The issue is how to test against these values when DTML cannot parse them? My raw sql query works fine giving me the desired results but I cannot construct the statement in DTML.

  The part of the query that throws the error is the dtml-sqltest tag (it gives a parsing error). ie.

  <dtml-and>
  <dtml-sqltest column=a_db.an_array_field[<dtml-sqlvar an_array_key type="int">][2] name=a_title op="eq" type="string" optional>

  should translate to:

  AND
  a_table.an_array_field[1][2] = 'This is a title' (This is a valid expression for Postgres)

  where an_array_key is a variable with value of 1 and a_title is variable with a value of 'This is a title' 

  The above would give an invalid attribute name error for the an_array_key (variable/argument).

  Is this a bug or is there something else I ought to be doing? If this is a limitation of DTML, is there a work around?

  Regards,
  David 






------------------------------------------------------------------------------


  _______________________________________________
  Zope maillist  -  Zope at zope.org
  http://mail.zope.org/mailman/listinfo/zope
  **   No cross posts or HTML encoding!  **
  (Related lists - 
   http://mail.zope.org/mailman/listinfo/zope-announce
   http://mail.zope.org/mailman/listinfo/zope-dev )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope/attachments/20050708/d973eb11/attachment.htm


More information about the Zope mailing list