Mercurial > p > roundup > code
changeset 1596:33a0d94c7658
searching on ranges of intervals is implemented
| author | Andrey Lebedev <kedder@users.sourceforge.net> |
|---|---|
| date | Sun, 20 Apr 2003 11:58:45 +0000 |
| parents | 1ae674595c04 |
| children | 4d55f90d4af1 |
| files | CHANGES.txt doc/upgrading.txt doc/user_guide.txt roundup/backends/back_anydbm.py roundup/backends/back_metakit.py roundup/backends/rdbms_common.py test/test_db.py |
| diffstat | 7 files changed, 88 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGES.txt Sat Apr 19 09:57:27 2003 +0000 +++ b/CHANGES.txt Sun Apr 20 11:58:45 2003 +0000 @@ -47,8 +47,9 @@ - added Node.get() method - nicer page titles (sf feature 65197) - relaxed CVS importing (sf feature 693277) -- added support for searching on ranges of dates (see doc/user_guide.txt in - chapter "Searching Page" for details) (closes sf feature 700178) +- added support for searching on ranges of dates and intervals (see + doc/user_guide.txt in chapter "Searching Page" for details) (closes sf + feature 700178) - role names made case insensitive - added ability to restore retired nodes - more lenient date input and addition Interval input support (sf bug 677764) @@ -56,7 +57,7 @@ - implemented ability to search for multilink properties with no value - Class.find() may now find unset Links (sf bug 700620) - more flexibility in classhelp link labelling (sf feature 608204) -- added command-line functionality for roundup-adming (sf feature 687664) +- added command-line functionality for roundup-admin (sf feature 687664) - added nicer popup windows for topic, nosy, etc (has add/remove buttons) thanks Gus Gollings - HTML templating files now have a .html extension
--- a/doc/upgrading.txt Sat Apr 19 09:57:27 2003 +0000 +++ b/doc/upgrading.txt Sun Apr 20 11:58:45 2003 +0000 @@ -70,7 +70,7 @@ timezone if he/she has provided timezone information. To make it possible some modification to tracker's schema and HTML templates are required. First you should add string property 'timezone' to user class in dbinit.py - like this: + like this:: user = Class(db, "user", username=String(), password=Password(), @@ -98,6 +98,25 @@ However you are not forced to make these modifications. By default roundup will assume timezone=0 and will work as previous versions did. + +0.6.0 Notes for metakit backend users +------------------------------------- + +- Roundup 0.6.0 introduced searching on ranges of dates and intervals. To + support it, some modifications to interval storing routine were made. So if + your tracker uses metakit backend and your db schema contains intervals + property, searches on that property will not be accurate for db items that + was stored before roundup' upgrade. However all new records should be + searchable on intervals. + + It is possible to convert your database to new format: you can export and + import back all your data (consult "Migrating backends" in "Maintenance" + documentation). After this operation all your interval properties should + become searchable. + + Users of backends others than metakit should not worry about this issue. + + Migrating from 0.4.x to 0.5.0 =============================
--- a/doc/user_guide.txt Sat Apr 19 09:57:27 2003 +0000 +++ b/doc/user_guide.txt Sun Apr 20 11:58:45 2003 +0000 @@ -2,7 +2,7 @@ User Guide ========== -:Version: $Revision: 1.19 $ +:Version: $Revision: 1.20 $ .. contents:: @@ -141,6 +141,8 @@ XXX explain... +When searching on interval properties use the same syntax as for dates. + Web Interface =============
--- a/roundup/backends/back_anydbm.py Sat Apr 19 09:57:27 2003 +0000 +++ b/roundup/backends/back_anydbm.py Sun Apr 20 11:58:45 2003 +0000 @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -#$Id: back_anydbm.py,v 1.118 2003-03-26 11:19:28 richard Exp $ +#$Id: back_anydbm.py,v 1.119 2003-04-20 11:58:45 kedder Exp $ ''' This module defines a backend that saves the hyperdatabase in a database chosen by anydbm. It is guaranteed to always be available in python @@ -1639,6 +1639,7 @@ MULTILINK = 1 STRING = 2 DATE = 3 + INTERVAL = 4 OTHER = 6 timezone = self.db.getUserTimezone() @@ -1695,18 +1696,21 @@ l.append((DATE, k, date_rng)) except ValueError: # If range creation fails - ignore that search parameter - pass + pass + elif isinstance(propclass, Interval): + try: + intv_rng = Range(v, date.Interval) + l.append((INTERVAL, k, intv_rng)) + except ValueError: + # If range creation fails - ignore that search parameter + pass + elif isinstance(propclass, Boolean): if type(v) is type(''): bv = v.lower() in ('yes', 'true', 'on', '1') else: bv = v l.append((OTHER, k, bv)) - # kedder: dates are filtered by ranges - #elif isinstance(propclass, Date): - # l.append((OTHER, k, date.Date(v))) - elif isinstance(propclass, Interval): - l.append((OTHER, k, date.Interval(v))) elif isinstance(propclass, Number): l.append((OTHER, k, int(v))) else: @@ -1760,7 +1764,7 @@ # RE search if node[k] is None or not v.search(node[k]): break - elif t == DATE: + elif t == DATE or t == INTERVAL: if node[k] is None: break if v.to_value: if not (v.from_value < node[k] and v.to_value > node[k]):
--- a/roundup/backends/back_metakit.py Sat Apr 19 09:57:27 2003 +0000 +++ b/roundup/backends/back_metakit.py Sun Apr 20 11:58:45 2003 +0000 @@ -1,4 +1,4 @@ -# $Id: back_metakit.py,v 1.45 2003-03-26 10:44:00 richard Exp $ +# $Id: back_metakit.py,v 1.46 2003-04-20 11:58:45 kedder Exp $ ''' Metakit backend for Roundup, originally by Gordon McMillan. @@ -603,10 +603,11 @@ if value is None: setattr(row, key, '') else: - setattr(row, key, str(value)) + # kedder: we should store interval values serialized + setattr(row, key, value.serialise()) changes[key] = str(oldvalue) propvalues[key] = str(value) - + elif isinstance(prop, hyperdb.Number): if value is None: value = 0 @@ -963,6 +964,10 @@ if date_rng.from_value: t = date_rng.from_value.get_tuple() where[propname] = int(calendar.timegm(t)) + else: + # use minimum possible value to exclude items without + # 'prop' property + where[propname] = 0 if date_rng.to_value: t = date_rng.to_value.get_tuple() wherehigh[propname] = int(calendar.timegm(t)) @@ -972,7 +977,24 @@ # If range creation fails - ignore that search parameter pass elif isinstance(prop, hyperdb.Interval): - where[propname] = str(date.Interval(value)) + try: + # Try to filter on range of intervals + date_rng = Range(value, date.Interval) + if date_rng.from_value: + #t = date_rng.from_value.get_tuple() + where[propname] = date_rng.from_value.serialise() + else: + # use minimum possible value to exclude items without + # 'prop' property + where[propname] = '-99999999999999' + if date_rng.to_value: + #t = date_rng.to_value.get_tuple() + wherehigh[propname] = date_rng.to_value.serialise() + else: + wherehigh[propname] = None + except ValueError: + # If range creation fails - ignore that search parameter + pass elif isinstance(prop, hyperdb.Number): where[propname] = int(value) else: @@ -1187,7 +1209,7 @@ if isinstance(prop, hyperdb.Date): value = int(calendar.timegm(value)) elif isinstance(prop, hyperdb.Interval): - value = str(date.Interval(value)) + value = date.Interval(value).serialise() elif isinstance(prop, hyperdb.Number): value = int(value) elif isinstance(prop, hyperdb.Boolean):
--- a/roundup/backends/rdbms_common.py Sat Apr 19 09:57:27 2003 +0000 +++ b/roundup/backends/rdbms_common.py Sun Apr 20 11:58:45 2003 +0000 @@ -1,4 +1,4 @@ -# $Id: rdbms_common.py,v 1.53 2003-04-08 06:41:48 richard Exp $ +# $Id: rdbms_common.py,v 1.54 2003-04-20 11:58:45 kedder Exp $ ''' Relational database (SQL) backend common code. Basics: @@ -1866,8 +1866,20 @@ where.append('_%s in (%s)'%(k, s)) args = args + [date.Interval(x).serialise() for x in v] else: - where.append('_%s=%s'%(k, a)) - args.append(date.Interval(v).serialise()) + try: + # Try to filter on range of intervals + date_rng = Range(v, date.Interval) + if (date_rng.from_value): + where.append('_%s > %s'%(k, a)) + args.append(date_rng.from_value.serialise()) + if (date_rng.to_value): + where.append('_%s < %s'%(k, a)) + args.append(date_rng.to_value.serialise()) + except ValueError: + # If range creation fails - ignore that search parameter + pass + #where.append('_%s=%s'%(k, a)) + #args.append(date.Interval(v).serialise()) else: if isinstance(v, type([])): s = ','.join([a for x in v])
--- a/test/test_db.py Sat Apr 19 09:57:27 2003 +0000 +++ b/test/test_db.py Sun Apr 20 11:58:45 2003 +0000 @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: test_db.py,v 1.84 2003-03-26 11:19:28 richard Exp $ +# $Id: test_db.py,v 1.85 2003-04-20 11:58:45 kedder Exp $ import unittest, os, shutil, time @@ -691,6 +691,7 @@ def testFilteringRange(self): ae, filt = self.filteringSetup() + # Date ranges ae(filt(None, {'deadline': 'from 2003-02-10 to 2003-02-23'}), ['2']) ae(filt(None, {'deadline': '2003-02-10; 2003-02-23'}), ['2']) ae(filt(None, {'deadline': '; 2003-02-16'}), ['1']) @@ -698,6 +699,11 @@ # may fail :) ae(filt(None, {'deadline': 'from 2003-02-16'}), ['2', '3']) ae(filt(None, {'deadline': '2003-02-16'}), ['2', '3']) + # Interval ranges + ae(filt(None, {'foo': 'from 0:50 to 2:00'}), ['1']) + ae(filt(None, {'foo': 'from 0:50 to 1d 2:00'}), ['1', '2']) + ae(filt(None, {'foo': 'from 5:50'}), ['2']) + ae(filt(None, {'foo': 'to 0:50'}), []) def testFilteringIntervalSort(self): ae, filt = self.filteringSetup()
