Roundup Tracker - Issues

Issue 1379534

classification
Add an orderprop used by Class.filter
Type: rfe Severity: normal
Components: Database Versions:
process
Status: closed fixed
:
: richard : richard, schlatterbeck
Priority: normal :

Created on 2005-12-13 14:34 by schlatterbeck, last changed 2006-01-20 02:41 by richard.

Files
File name Uploaded Description Edit Remove
patch-orderprop schlatterbeck, 2005-12-13 14:34 patch for configuring order attribute
patch-orderprop2 schlatterbeck, 2006-01-13 16:00 corrected patch (was wrong for mysql)
patch-orderprop-doc schlatterbeck, 2006-01-16 10:32 Add docstring to orderprop method
Messages
msg3398 Author: [hidden] (schlatterbeck) Date: 2005-12-13 14:34
Currently if sorting by a Link property with no 'order'
property defined, different backends behave differently:
- SQL backends sort by 'id'
- Metakit sorts by labelprop
- anydbm sorts by getkey()

The attached patch introduces a new function orderprop
into hyperdb.Class and a setorderprop method to set the
ordering property. It patches all the backends to use
the new property.
The new sort-property resolution order is as follows:
- If an order property was defined using setorderprop,
this property is used
- If a property named 'order' is defined it is used
- labelprop is used

This unifies behaviour across backends. For people
*really* wanting to sort by id, they can get the old
SQL backend behaviour using setorderprop ('id').

The patch may be off by some lines, I've used my
previous patch introducing setlabelprop as the base. If
needed I can resubmit the patch against a given source.

Note that the "filter" method of Class uses a lot of
redundant code for mysql and the other sql-based
backends. I have not dared to refactor this without a
regression test in place (and a mysql installation to
run the test).

The patch is only tested with the postgres backend.

I'm unsure about the anydbm backend: If 'id' is
returned by orderprop(), I set the sortkey to None --
simulating the old behaviour. I'm not sure if the id
attribute behaves as all other attributes for sorting
(or if it is naturally sorted by key anyway).

-- Ralf
msg3399 Author: [hidden] (schlatterbeck) Date: 2006-01-13 16:00
Logged In: YES 
user_id=34818

I wrote:
> Note that the "filter" method of Class uses a lot of
> redundant code for mysql and the other sql-based
> backends
Seems this bit me here. See attached patch that corrects the
code for mysql (an underscore was missing).
msg3400 Author: [hidden] (schlatterbeck) Date: 2006-01-16 10:32
Logged In: YES 
user_id=34818

Update for python docstring for orderprop. Attached patch is
relative to the already-appended patch.
msg3401 Author: [hidden] (schlatterbeck) Date: 2006-01-16 10:40
Logged In: YES 
user_id=34818

See
https://sourceforge.net/tracker/index.php?func=detail&aid=1379490&group_id=31577&atid=402791
for a patch updating the documentation for the new feature.
msg3402 Author: [hidden] (richard) Date: 2006-01-20 02:41
Logged In: YES 
user_id=6405

applied, thanks! 
History
Date User Action Args
2005-12-13 14:34:07schlatterbeckcreate