the right way to do it is to extract a field from the database (lets call it "field") and then: <dtml-if "_['count-field'] == 1"> ... <dtml-else> ... </dtml-if> Scavenging the mail folder uncovered Brad Clements's letter:
I want to be able to do something like this:
<dtml-in "GetDB()[Table][Indice][Rec].fetchall()"> <dtml-with "_['sequence-item']"> <dtml-if "_['sequence-size'] == 1"> <dtml-var "tableFromView(URL=URL0)"> <dtml-else> <dtml-var "tableFromView(viewName='DefaultLocatorView',URL=URL0)"> </dtml-if> </dtml-with> </dtml-in>
That is, produce different output depending on the number of items returned from dtml-in.
There isn't a "sequence-size" variable. I thought "batch-size" would work, but that doesn't seem to exist either, even when I use "size=nn" in the dtml-in statement.
I know I can use total-nnn, but then I need to know an attribute name. In this case, I do *not* know any of the attributes in the objects returned from fetchall().
Therefore I'm stuck doing something like this:
<dtml-if "_.len(GetDB()[Table][Indice][Rec].fetchall()) == 1"> <dtml-var "GetDB()[Table][Indice][Rec].fetchone().tableFromView(URL=URL0)"> <dtml-else> <dtml-in "GetDB()[Table][Indice][Rec].fetchall()"> <dtml-with "_['sequence-item']"> <dtml-var "tableFromView(viewName='DefaultLocatorView',URL=URL0)"> </dtml-with> </dtml-in>
This is ugly, and unlike SQLMethods, the value returned from fetchall() is not cached. (not sure if DTML caches the result of the call or not)
FYI, I'm using SQLDict.py here, and its very nice. Next step is to emulate a DB interface using Zope Database Adapters. This way I can test my core logic outside of Zope, but work with the transaction machinery inside zope.
Brad Clements, bkc@murkworks.com (315)268-1000 http://www.murkworks.com (315)268-9812 Fax netmeeting: ils://ils.murkworks.com AOL-IM: BKClements
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
-- Federico Di Gregorio MIXAD LIVE System Programmer fog@mixadlive.com Debian GNU/Linux Developer & Italian Press Contact fog@debian.org Put a GNOME on your desktop! [http://www.gnome.org] -- brought to you by One Line Spam