[Zope] "REQUEST" a string object?

Rob Miller rob.at.kalistra.dot.com@zope.org
Sun, 23 Jul 2000 20:11:55 -0700


Arrggh!  I'm getting very frustrated trying to accomplish something that should
be easy.  I'm stepping through all of the files in a LocalFS directory, and I
want to dynamically create a <table> that displays all of the sub-directories
of the current directory.  I want to inject a "</tr><tr>" every so often, so I
need to count the number of directories I've found so far to see whether I need
to start a new row or not.

I've spent a few hours digging through the list archives, so I know that
creating a manually managed counter variable is not a straightforward affair. 
Here's the code that I have:


<table>
<dtml-call "REQUEST.set('ctr', 0)">
<dtml-in "fileValues(REQUEST.get('spec', _.None))">
  <dtml-if "type == 'directory'">
    <dtml-if "ctr % num_dir_columns == 0">
      <tr>
    </dtml-if>
    <a href="<dtml-var URL1>/<dtml-var url>"><dtml-var "id"></a><br>
    <dtml-if "ctr % num_dir_columns == num_dir_columns - 1">
      </tr>
    </dtml-if>
    <dtml-call "REQUEST.set('ctr', _.int(ctr) + 1)">
  </dtml-if>
</dtml-in>
<dtml-comment> In case we end in the middle of a row... </dtml-comment>
<dtml-if "ctr % num_dir_columns != 0">
  </tr>
</dtml-if>
</table>


The error I get, running Zope in debug mode, is this:

   Error Type: AttributeError
   Error Value: 'string' object has no attribute 'set'

This is referring to the <dtml-call> line in the middle of the loop, the one
that actually does the incrementing.  It thinks that REQUEST is a string, which
of course doesn't have a "set" attribute.  I've been banging my head on this
all day and can't come up with an way to accomplish this trivial task.  I don't
want to push this into Python; this is simple UI code, not business logic, so
it doesn't belong there.  Besides, it's absurd to think that I would need to
write an external method or some other Python method to do something as simple
as this.  (It may end up being true, but it's still absurd... ;-) )

Any help would be greatly appreciated.

thanks for your time,

rob