Re: [Zope] problems sorting with in-tag
At 14:54 31/05/99 , Sebastian Luehnsdorf wrote:
hi!
i got a problem trying to sort the results from an in tag. i have three different conditions, and want to unite these into one solution. something like
<!--#in "..." sort=sortby-->
where 'sortby' designates the variable to be sorted by. now i would like to access the document with the in tag like this:
abc.dtml?sortby=thisval
this doesn't work. what am i doing wrong?
ciao, basti
The sort attribute cannot be dynamically assigned.. What happens is this: DTML is pre-parsed, and all the DTML tags are replaced by object instances representing those tags. The attributes are stored as instance variables. This means that 'sortby' is evaluated only once, when you save the DTML code. Right now there is no real solution to your problem, other then creating different #in tags and selecting one with an if - elseif - else structure. -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-6254545 Fax: +31-35-6254555 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
I too have spent two days trying to do exactly this. I tried: <!--#in aTinyTable sort="<--#var sortby-->"--> I eventually found on the zope.org site under Advanced DTML the statement that the above is illegal and that you really don't need it. They didn't offer any further explanation! Martijn's response explains why it can't be done, and offers the solution that one could use conditionals to select different #in alternatives. This didn't work for me either. I believe because an #in must be matched by a #/in within an enclosing conditional. My problem is combinatorially worse because I wish to add filters to the #in also. Apparently the developers didn't notice this problem because they always create tables in an SQL database and rely on a SQL method to do the sorting and filtering. Come to think of it I remember seeing a database that could use comma separated fields like TinyTable does. Maybe that has a SQL interface. The hunt goes on... Larry
On 31 May 1999 16:40:01 -0500, Larry Luther wrote:
I too have spent two days trying to do exactly this.
I tried: <!--#in aTinyTable sort="<--#var sortby-->"-->
I eventually found on the zope.org site under Advanced DTML the statement that the above is illegal and that you really don't need it. They didn't offer any further explanation!
[...]
Apparently the developers didn't notice this problem because they always create tables in an SQL database and rely on a SQL method to do the sorting and filtering. Come to think of it I remember seeing a database that could use comma separated fields like TinyTable does. Maybe that has a SQL interface. The hunt goes on...
The next version of TinyTables will allow you to query for the column names and use that to iterate over, which might be rather 'interesting' to implement with SQL methods. However, the ability to query for column names quickly illuminates this static name limitation in DTML. Actually, this issue of not being able to query for column names and dynamically build tabular results with the query results in SQL methods was one of the two primary reasons for the TinyTables concept. With my TinyTables-like filesystemed database application (which has the new new TinyTables column name query also, along with the new VSEval() query method), I found that in addition to the 'sort=' problem, the statistics method names operate with the same limitation and can't be assigned dynamically. I ended up writing Python methods which dynamically build the dtml and then render it with HTML(). It's a little inconvenient, but it works fine. Actually, I dumped the 'sort=' and now call an 'orderby()' method which sorts the entire table by the column order which I provide dynamically. I have another method which allows me to dynamically arrange the order of the column names, which I then iterate over in dtml to arrange the column order. I sent the stuff to Ty, but I'm not sure how well it could be implemented in TinyTables as my stuff is application-specific enough that I can cut some corners and not have to be so general. I expect Ty would need to consider whether it is really important enough to implement in TinyTables and then determine if there is a general way to implement it. I'm also looking at a more general solution, but I can live with what I have for now. :^) Kent
participants (3)
-
kent@tiamat.goathill.org -
Larry Luther -
Martijn Pieters