Reasons
- Less Complexity
The new tools::paginate is much simpler while keeping many of the backward compatible features of ad_table/paginate. - Real Sorting
Unlike Paginate/ad_table, tools::paginate returns the selected rows after sorting. - Scalabity
This proc is being used in production, and has scaled well to 1500 pages (15000 records). It doesn’t depend on caching and all the work is done in the db server. This means it is as fast as your query plus a little (very little) overhead to do the limit.
Place the following files in your acs-tcl/tcl dir (or somewhere they will get sourced).
tools-procs.tcl
tools-procs-oracle.xql
tools-procs-postgresql.xql
tools-procs.xql
tools-procs.tar.gz
Here is a link to the sample files:
index.tcl.txt
index.xql.txt
index.adp.txt
.tcl
ad_page_contract {@author Jon Griffin jon@mayuli.com@creation-date 01 April 2003 @cvs-id@ $Id$ Sample page for ad_table/paginator integration. } { {extra_stuff:optional ""} {objects_page:optional "1"} {objects_orderby:optional "object_type"} {objects_context:optional ""}}set title "tools::paginate Sample"set context $titlelset extra_stuff "extra"lappend extra_stuff "stuff"
set orderby "order by $objects_orderby"set context_column "object_type"
if {[empty_string_p $objects_context] } {set context_clause ""
} else {set context_clause "where upper($context_column) like '$objects_context%'"
}set table_info {
{object_type "Type" {object_type} l }{creation_date "Creation Date" {creation_date} "<td>\n
<a href=\"edit-object?object_id=$object_id\">$creation_date</a> $extra_stuff\n</td>\n "}}
set sample_html [tools::paginate -name objects -page objects_page \-queryname get_objects -context_field "object_type" -array_name object_paginate_info \
-table_info $table_info -extra_vars [list extra_stuff]]
ad_return_template
.adp
<master><property name="context">@context@</property><property name="title">@title@</property><table><tr>
<th class="paginate-blue">Objects</th> </tr>
<tr> <td>
@object_paginate_info.paginator@ @object_paginate_info.html@
</td> </tr>
</table>
.xql
<?xml version="1.0"?><queryset><fullquery name="get_objects"><querytext> select object_id,object_type,to_char(creation_date,'MM/DD/YYYY HH:MI') as creation_date from acs_objects a
$context_clause$orderby
</querytext></fullquery>
</queryset>
Caveats
Make sure you set a default order by, if not Postgresql will not guarantee the order of rows returned.I have not implemented all aspects of ad_table yet, but most of them are.
Version 0.4 By Jon Griffin
This document is Copyright © 2002-03 Jon Griffin.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License”.

No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.
