[Zope] complex question

Sam Gendler sgendler@teknolojix.com
Thu, 04 Nov 1999 23:40:29 -0800


I have a table containing attributes (attribute_id,
attribute_name_string), and I have a table associating an object_id with
0 or more attributes (object_id, attribute_id).  I want to populate a
sequence of checkboxes in a dtml doc that has a checkbox for every
attribute, but only the attributes assigned to the current object are
checked.  I cannot seem to generate sql that returns a table that
contains all attribute_ids and attribute_name_strings, but only has
object_ids on the rows for attributes assigned to that object, so I need
to do it by querying for all attributes and then looping through the
assigned attributes, looking for a match.  However, I can't seem to do
that, since having nested <dtml-in> tags creates a conflict, since both
queries need to return an attribute_id field, and I need to compare the
attribute_ids of both queries.

That made no sense, so here is an example.

qrySelectAllAtt returns a complete list of (att_id, att_string)
qrySelectObjAtt returns a list of all (obj_id, att_id) where obj_id=x

<dtml-in qrySelectAllAtt>
  <input name="blah" type="checkbox" value="blah"
  <dtml-in qrySelectObjAtt>
THIS NEXT LINE DOESN'T WORK
    <dtml-if qrySelectObjAtt.att_id == qrySelectAllAtt.att_id>
      checked>
      <dtml-break>
    </dtml-if>
    >
  </dtml-in>
</dtml-in>

Of course, I would prefer some SQL that would generate the table I want
in a single query.  Perhaps someone who understands all the funky
<dtml-sql> commands coould help me out.

Alternatively, I wrote an external method that can do this loop, no
problem.  However, This is just a small piece of a huge form, and most
of the form is based off yet another, simple query.  I would like to
build a dtml doc on that simple query that builds the bulk of the form,
and then call that doc from inside the external method.  

I can call my dtml document from the external method, but it doesn't
receive the REQUEST object (or the folder object), so the query fails to
execute.  I cannot figure out how to pass variables into the dtml doc
(or method) from my external method.  Is this possible?  Without the
self (folder) object, the dtml document can do nothing but spit out
straight html.  

I still prefer the single query method, however, as it allows the query
to only run once, instead of several times in a loop.

--sam