Mercurial > p > roundup > code
diff roundup/backends/back_metakit.py @ 1508:5c58ccad41ee
Searches on range of dates for metakit
| author | Andrey Lebedev <kedder@users.sourceforge.net> |
|---|---|
| date | Mon, 10 Mar 2003 20:24:30 +0000 |
| parents | e6ac4e074acb |
| children | 6fede2aa6a12 |
line wrap: on
line diff
--- a/roundup/backends/back_metakit.py Mon Mar 10 20:23:41 2003 +0000 +++ b/roundup/backends/back_metakit.py Mon Mar 10 20:24:30 2003 +0000 @@ -1,3 +1,4 @@ +# $Id: back_metakit.py,v 1.41 2003-03-10 20:24:30 kedder Exp $ ''' Metakit backend for Roundup, originally by Gordon McMillan. @@ -34,6 +35,7 @@ import re, marshal, os, sys, weakref, time, calendar from roundup import indexer import locking +from roundup.date import Range _dbs = {} @@ -852,7 +854,11 @@ # filterspec is a dict {propname:value} # sort and group are (dir, prop) where dir is '+', '-' or None # and prop is a prop name or None + + timezone = self.db.getUserTimezone() + where = {'_isdel':0} + wherehigh = {} mlcriteria = {} regexes = {} orcriteria = {} @@ -906,8 +912,20 @@ bv = value where[propname] = bv elif isinstance(prop, hyperdb.Date): - t = date.Date(value).get_tuple() - where[propname] = int(calendar.timegm(t)) + try: + # Try to filter on range of dates + date_rng = Range(value, date.Date, offset=timezone) + if date_rng.from_value: + t = date_rng.from_value.get_tuple() + where[propname] = int(calendar.timegm(t)) + if date_rng.to_value: + t = date_rng.to_value.get_tuple() + wherehigh[propname] = int(calendar.timegm(t)) + else: + wherehigh[propname] = None + except ValueError: + # If range creation fails - ignore that search parameter + pass elif isinstance(prop, hyperdb.Interval): where[propname] = str(date.Interval(value)) elif isinstance(prop, hyperdb.Number): @@ -917,7 +935,9 @@ v = self.getview() #print "filter start at %s" % time.time() if where: - v = v.select(where) + where_higherbound = where.copy() + where_higherbound.update(wherehigh) + v = v.select(where, where_higherbound) #print "filter where at %s" % time.time() if mlcriteria:
