Changeset 648
- Timestamp:
- 03/28/07 08:35:47
- Files:
-
- PCL/trunk/PCL-Core/cartography/data/postgis.py (modified) (2 diffs)
- PCL/trunk/PCL-Core/tests/testpgfeatures.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
PCL/trunk/PCL-Core/cartography/data/postgis.py
r631 r648 98 98 from zope.interface import implements 99 99 100 PATTERN_ATTR_WITHOUT_F=re.compile(r"[^f](\[[a-z 0-9_\"\']+\])|^(\[[a-z 0-9_\"\']+\])") 101 PATTERN_ATTR=re.compile(r"\[([a-z 0-9_\"\']+)\]") 100 102 101 103 # ============================================================================ … … 770 772 self.hasfrontfilter = 0 771 773 if filter is not None: 774 while 1: 775 match = PATTERN_ATTR_WITHOUT_F.search(filter) 776 if not match: 777 break; 778 repl = match.group(1) or match.group(2) 779 attrMatch = PATTERN_ATTR.search(repl) 780 if attrMatch.group(1)[0] not in ["'", '"']: 781 unquotedAttr = attrMatch.group(1) 782 filter = filter.replace(repl,"f['"+unquotedAttr+"']") 783 else: 784 filter = filter.replace(repl,"f"+repl) 785 772 786 self._compiled_filter = compile(filter, 'string', 'eval') 773 787 self._locals = {} PCL/trunk/PCL-Core/tests/testpgfeatures.py
r544 r648 355 355 i += 1 356 356 self.assert_(i == 46, i) 357 def filter_test(self,subfilt): 358 b = BoundingBox(-10, 45, 10, 60) 359 source = self.store.source(TYPENAME0, bbox=b) 360 def func(s): 361 return s.lower() 362 ff = "func(%s) == 'uk'" % subfilt 363 fiter = source(filter=ff, func=func) 364 i = 0 365 for feature in fiter: 366 i += 1 367 self.assert_(i == 46, subfilt) 368 def test_filters(self): 369 for filt in ( "[fips_cntry]", "['fips_cntry']", '["fips_cntry"]', 370 "f['fips_cntry']", "f.fips_cntry"): 371 self.filter_test(filt) 357 372 def test_front_geom(self): 358 373 b = BoundingBox(-10, 45, 10, 60)
