Mercurial > p > roundup > code
diff roundup/backends/back_metakit.py @ 2603:5ccd99777869
fix metakit handling of filter on Link==None; fix some unit tests
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Tue, 20 Jul 2004 23:24:27 +0000 |
| parents | 113548baeed2 |
| children | a9e1fff1e793 |
line wrap: on
line diff
--- a/roundup/backends/back_metakit.py Tue Jul 20 22:59:53 2004 +0000 +++ b/roundup/backends/back_metakit.py Tue Jul 20 23:24:27 2004 +0000 @@ -1,4 +1,4 @@ -# $Id: back_metakit.py,v 1.80 2004-07-20 22:56:18 richard Exp $ +# $Id: back_metakit.py,v 1.81 2004-07-20 23:24:26 richard Exp $ '''Metakit backend for Roundup, originally by Gordon McMillan. Known Current Bugs: @@ -84,6 +84,9 @@ self.indexer = Indexer(self.config.DATABASE, self._db) self.security = security.Security(self) + self.stats = {'cache_hits': 0, 'cache_misses': 0, 'get_items': 0, + 'filtering': 0} + os.umask(0002) def post_init(self): @@ -1189,10 +1192,8 @@ property value to match is a list, any one of the values in the list may match for that property to match. ''' - # search_matches is None or a set (dict of {nodeid: {propname:[nodeid,...]}}) - # 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 + if __debug__: + start_t = time.time() timezone = self.db.getUserTimezone() @@ -1227,10 +1228,14 @@ # transform keys to ids u = [] for item in value: - try: - item = int(item) - except (TypeError, ValueError): - item = int(self.db.getclass(prop.classname).lookup(item)) + if item is None: + item = -1 + else: + try: + item = int(item) + except (TypeError, ValueError): + linkcl = self.db.getclass(prop.classname) + item = int(linkcl.lookup(item)) if item == -1: item = 0 u.append(item) @@ -1300,12 +1305,10 @@ else: where[propname] = str(value) v = self.getview() - #print "filter start at %s" % time.time() if where: where_higherbound = where.copy() where_higherbound.update(wherehigh) v = v.select(where, where_higherbound) - #print "filter where at %s" % time.time() if mlcriteria: # multilink - if any of the nodeids required by the @@ -1321,8 +1324,6 @@ return 0 iv = v.filter(ff) v = v.remapwith(iv) - - #print "filter mlcrit at %s" % time.time() if orcriteria: def ff(row, crit=orcriteria): @@ -1335,7 +1336,6 @@ iv = v.filter(ff) v = v.remapwith(iv) - #print "filter orcrit at %s" % time.time() if regexes: def ff(row, r=regexes): for propname, regex in r.items(): @@ -1346,7 +1346,6 @@ iv = v.filter(ff) v = v.remapwith(iv) - #print "filter regexs at %s" % time.time() if sort or group: sortspec = [] @@ -1381,7 +1380,6 @@ rev.append(prop) sortspec.append(prop) v = v.sortrev(sortspec, rev)[:] #XXX Metakit bug - #print "filter sort at %s" % time.time() rslt = [] for row in v: @@ -1391,6 +1389,10 @@ rslt.append(id) else: rslt.append(id) + + if __debug__: + self.db.stats['filtering'] += (time.time() - start_t) + return rslt def hasnode(self, nodeid):
