Mercurial > p > roundup > code
comparison roundup/support.py @ 3636:fa7becc62534
Of course for Links there is the same bug as I fixed before for multilinks.
But it turns out that searching for None is valid for a link. So we
can't use None as a guard in support.Proptree, I introduced the
has_values flag there and use it in the sql search too.
| author | Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net> |
|---|---|
| date | Thu, 13 Jul 2006 13:30:39 +0000 |
| parents | 53987aa153d2 |
| children | f35ece8f8ff7 |
comparison
equal
deleted
inserted
replaced
| 3635:53987aa153d2 | 3636:fa7becc62534 |
|---|---|
| 123 | 123 |
| 124 class Proptree(object): | 124 class Proptree(object): |
| 125 ''' Simple tree data structure for optimizing searching of properties | 125 ''' Simple tree data structure for optimizing searching of properties |
| 126 ''' | 126 ''' |
| 127 | 127 |
| 128 def __init__(self, db, cls, name, props, parent = None, val = None): | 128 def __init__(self, db, cls, name, props, parent = None): |
| 129 self.db = db | 129 self.db = db |
| 130 self.name = name | 130 self.name = name |
| 131 self.props = props | 131 self.props = props |
| 132 self.parent = parent | 132 self.parent = parent |
| 133 self._val = val | 133 self._val = None |
| 134 self.has_values = False | |
| 134 self.cls = cls | 135 self.cls = cls |
| 135 self.classname = None | 136 self.classname = None |
| 136 self.uniqname = None | 137 self.uniqname = None |
| 137 self.children = [] | 138 self.children = [] |
| 138 self.propnames = {} | 139 self.propnames = {} |
| 169 | 170 |
| 170 def _set_val(self, val): | 171 def _set_val(self, val): |
| 171 """Check if self._val is already defined. If yes, we compute the | 172 """Check if self._val is already defined. If yes, we compute the |
| 172 intersection of the old and the new value(s) | 173 intersection of the old and the new value(s) |
| 173 """ | 174 """ |
| 174 if self._val: | 175 if self.has_values: |
| 175 v = self._val | 176 v = self._val |
| 176 if not isinstance(self._val, type([])): | 177 if not isinstance(self._val, type([])): |
| 177 v = [self._val] | 178 v = [self._val] |
| 178 vals = Set(v) | 179 vals = Set(v) |
| 179 vals.intersection_update(val) | 180 vals.intersection_update(val) |
| 180 self._val = [v for v in vals] | 181 self._val = [v for v in vals] |
| 181 else: | 182 else: |
| 182 self._val = val | 183 self._val = val |
| 184 self.has_values = True | |
| 183 | 185 |
| 184 val = property(lambda self: self._val, _set_val) | 186 val = property(lambda self: self._val, _set_val) |
| 185 | 187 |
| 186 def __iter__(self): | 188 def __iter__(self): |
| 187 """ Yield nodes in depth-first order -- visited nodes first """ | 189 """ Yield nodes in depth-first order -- visited nodes first """ |
