[Zope] ANN: Zieve 0.1.0 no longer needs cookies.. flexible sorting...

Steve Spicklemire steve@spvi.com
Tue, 11 Jul 2000 21:41:22 -0500 (EST)


On the list I've often seen complaints about 

<dtml-in foo sort=blah.... > not being dynamic enough. I cooked
up a solution some time ago "Zieve", but the first release required
each user to get a cookie to store their preferred sort order, and
to rank sort order according to the history of their clicks. Zieve-0-1-0
still allows that behavior, but no longer requires it. Below is the current
REAME. Let me know if it works for you! Since cookies are not needed
you can drop a Zieve in at the root of your project and acquire it anywhere
below that. It can then be called on as sort of a 'helper' to sort in all
sorts of situations. You can sort on any attributes, in any order. Anyway,
if *you're* frustrated with sorting problems... check it out!

http://www.zope.org/Members/sspickle/Zieve

-steve

----------------------------------------------------------------------

README.txt:

Zieve 0-1-0

Zieve is a Z-subclassable class that assists in sorting arbitrary Zope
Objects in various ways. It allows developers to sort objects
dynamically with primary, secondary etc keys, and provides an
easy means to include dynmically sortable objects in other documents.

What's New in 0-1-0: 

  * No longer requires Cookies! (Yeah!)

  * More logical parameter names.

What was new last time:

  * A snappy new icon. ;-) 

  * Stand alone product, no longer needs to be subclassed 
    to be useable. 

  * Example table in manage_tabs for perusal 

  * Editing of meta_types and default sort order from management 
    interface reduces coding in dtml docs..

Here is some DTML from a DTMLMethod that uses a zclass derived 
from Zieve to do some sorting...

This displays a table heading with links that dynamically resort the
table according to which link was clicked last. The secondary,
tertiary, ...etc keys are remembered from prior clicks....

Here is an example::
  
  <dtml-var standard_html_header>
  <h2><dtml-var title_or_id></h2>
  
  <!-- 
  'theZieve' is a Zieve or an instance of a ZClass that is subclassed from Zieve.
  'name', 'color', 'birthsone', 'number' are all properties of the objects being sorted.
  (in this case, they are DTML Documents with properties 'name' etc....) The format 'name:format' 
  allows you to specify a type or filter to use before comparison. In this case 'number:int' 
  allows numerical sorting for one of the properties.
  -->
  
  <dtml-in "theZieve.sortObjects( 
             theObjects = objectValues(['DTML Document']), 
	     sortOrder=REQUEST.get('sortOrder','name:color'))">
  
  <dtml-if sequence-start>
  <center><table>
  <tr>
  <td><a href="&dtml-URL0;?sortOrder=name">name</a></td>
  <td><a href="&dtml-URL0;?sortOrder=color">color</a></td>
  <td><a href="&dtml-URL0;?sortOrder=birthstone">birthstone</a></td>
  <td><a href="&dtml-URL0;?sortOrder=number:int">number</a></td>
  </tr>
  </dtml-if>
  
  <dtml-with sequence-item>
  <tr>
  <td><dtml-var name></td>
  <td><dtml-var color></td>
  <td><dtml-var birthstone></td>
  <td><dtml-var number></td>
  </tr>
  </dtml-with>
  
  <dtml-if sequence-end>
  </table></center>
  </dtml-if>
  
  <dtml-else>
  Sorry.. there are no objects to sort..
  
  </dtml-in>
  <dtml-var standard_html_footer>
  
----------------------------------------------------------------------

Of course.. a Zieve is smart enough to display objects in a sortable table
all on it's own, if you like... Just 'view' it!

steve@spvi.com