Example #1
0
    def getCurrentConditions(self):
        cache = getInstance()
        cache_key = 'ColoradoWater_StationCurrentConditions-'+str(self.waterDist.divID)+"-"+str(self.waterDist.wdID)+"-"+str(self.abbrev)
#        if self.currentConditions is None:
#            self.currentConditions = cache.get(cache_key)
            
        if self.currentConditions is None:
            self.currentConditions = StationConditions(self.waterDist.divID, self.waterDist.wdID, self.abbrev)
            cache.set(cache_key, self.currentConditions, exp=86400)
            
        return self.currentConditions
Example #2
0
def getDistricts():
    global _districts
    cache = getInstance()
    
    if _districts is None:
        _districts = cache.get('ColoradoWater_Districts')
        
    if _districts is None:
        dists = coloradoWaterService.service.GetWaterDistricts()
        districts = []
        for district in dists.WaterDistrict:
            districts.append(WaterDistrict(response=district))
        _districts = districts
        
        cache.set('ColoradoWater_Districts', _districts, exp=86400)
        
    return _districts
Example #3
0
 def getStations(self):
     cache = getInstance()
     cache_key = 'ColoradoWater_Stations-'+str(self.divID)+"-"+str(self.wdID)
     if self.stations is None:
         self.stations = cache.get(cache_key)
         if self.stations is not None:
             #Set Correct Ref to self
             for station in self.stations:
                 station.waterDist = self
         
     if self.stations is None:
         self.stations = []
         response = coloradoWaterService.service.GetSMSTransmittingStations(self.divID, self.wdID)
         self.stations = []
         try:
             for station in response.Station:
                 self.stations.append(Station(response=station, waterDist=self))
         except AttributeError, e:
             #This tends to be no stations for a district
             pass
             
         cache.set(cache_key, self.stations, exp=86400)