Changeset 1228
- Timestamp:
- 11/14/07 14:53:30 (1 year ago)
- Files:
-
- PleiadesGeocoder/trunk/geo.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
PleiadesGeocoder/trunk/geo.py
r1227 r1228 35 35 from Products.ATContentTypes.interface.topic import IATTopic 36 36 from Products.ATContentTypes.interface.folder import IATFolder 37 from Products.ATContentTypes.interface.folder import IATBTreeFolder 37 38 38 39 from Products.PleiadesGeocoder.interfaces import IGeoItemSimple \ 39 40 , IGeoCollectionSimple, IGeoreferencedEvent 41 42 import logging 43 44 logger = logging.getLogger('PleiadesGeocoder.geo') 40 45 41 46 … … 158 163 if IATTopic.providedBy(self.context): 159 164 for ob in self.context.queryCatalog(): 160 try:161 item = IGeoItemSimple(ob.getObject())162 assert(item.isGeoreferenced())163 e xcept:165 item = self._adapt(ob.getObject()) 166 if item is not None: 167 yield item 168 else: 164 169 continue 170 elif (IATFolder.providedBy(self.context) or 171 IATBTreeFolder.providedBy(self.context)): 172 for ob in self.context.listFolderContents(): 173 item = self._adapt(ob) 174 if item is not None: 175 yield item 176 else: 177 continue 178 # Last resort: single objects may yield geoItems 179 else: 180 item = self._adapt(self.context) 181 if item is not None: 165 182 yield item 166 elif IATFolder.providedBy(self.context): 167 for ob in self.context.listFolderContents(): 168 try: 169 item = IGeoItemSimple(ob) 170 assert(item.isGeoreferenced()) 171 except: 172 continue 173 yield item 174 else: 175 try: 176 item = IGeoItemSimple(self.context) 177 assert(item.isGeoreferenced()) 178 except: 179 pass 180 yield item 183 184 def _adapt(self, ob): 185 try: 186 item = IGeoItemSimple(ob) 187 if item.isGeoreferenced(): 188 return item 189 else: 190 logger.debug("%s is not georeferenced" % item) 191 except TypeError: 192 logger.debug("Could not adapt %s to IGeoItemSimple" % self.context) 193 return None 181 194 182 195
