def coordsfromchapterkey(self,chapter): domain = 'http://jandj.gldnfleece.com/' zipcoordsdata = {} countycoordsdata = {} c = [] for county in chapter.countyinds: s = helpers.stateforcounty(county,chapter.state) countyind = county.split('|')[0] try: dataarr = countycoordsdata[s] coords = helpers.getcoordsfromindex(dataarr, countyind) except KeyError: countycoordsdata[s] = helpers.prepcoordsfile(domain + 'data/' + s + '/county/complex.txt') coords = helpers.getcoordsfromindex(countycoordsdata[s], countyind) if coords: c.append(map(' '.join,coords)) for zipcode in chapter.zipinds: s = helpers.stateforzip(zipcode,chapter.state) zipind = zipcode.split('|')[0] try: dataarr = zipcoordsdata[s] coords = helpers.getcoordsfromindex(dataarr, zipind) except KeyError: zipcoordsdata[s] = helpers.prepcoordsfile(domain + 'data/' + s + '/zip/complex.txt') coords = helpers.getcoordsfromindex(zipcoordsdata[s], zipind) if coords: c.append(map(' '.join,coords)) return c
def coordsfromchapterkey(self, chapter): domain = 'http://jandj.gldnfleece.com/' zipcoordsdata = {} countycoordsdata = {} c = [] for county in chapter.countyinds: s = helpers.stateforcounty(county, chapter.state) countyind = county.split('|')[0] try: dataarr = countycoordsdata[s] coords = helpers.getcoordsfromindex(dataarr, countyind) except KeyError: countycoordsdata[s] = helpers.prepcoordsfile( domain + 'data/' + s + '/county/complex.txt') coords = helpers.getcoordsfromindex(countycoordsdata[s], countyind) if coords: c.append(map(' '.join, coords)) for zipcode in chapter.zipinds: s = helpers.stateforzip(zipcode, chapter.state) zipind = zipcode.split('|')[0] try: dataarr = zipcoordsdata[s] coords = helpers.getcoordsfromindex(dataarr, zipind) except KeyError: zipcoordsdata[s] = helpers.prepcoordsfile(domain + 'data/' + s + '/zip/complex.txt') coords = helpers.getcoordsfromindex(zipcoordsdata[s], zipind) if coords: c.append(map(' '.join, coords)) return c
def post(self): #query database to see if this entry already exists (query by chaptername and state) domain = 'http://jandj.gldnfleece.com/' if self.request.get('chapterkey'): chapter = models.getchapter(self.request.get('chapterkey')) else: region = models.getregionfromstate( self.request.get('chapterstate').upper()) if region: chapter = models.Chapter(parent=region.key()) else: chapter = models.Chapter() zips = self.request.get('chapterzips') counties = self.request.get('chaptercounties') chapter.name = self.request.get('chaptername') chapter.state = self.request.get('chapterstate').upper() if zips: chapter.zips = map(helpers.mapstrip, zips.split(",")) else: chapter.zips = [] if counties: chapter.counties = map(helpers.mapstrip, counties.split(",")) else: chapter.counties = [] countyindexdata = {} chapter.countyinds = [] for county in chapter.counties: s = helpers.stateforcounty(county, chapter.state) countyname = county.split("|")[0] try: dataarr = countyindexdata[s] ind = helpers.findcountyindex(dataarr, countyname) except KeyError: #add dataarr to dict of state data arrays countyindexdata[s] = helpers.prepindexfile( domain + 'data/' + s + '/county/simple.txt') ind = helpers.findcountyindex(countyindexdata[s], countyname) if not isinstance(ind, str): self.response.out.write(self.errorstr(ind)) return chapter.countyinds.append(ind + '|' + s) zipindexdata = {} chapter.zipinds = [] ziperrors = [] for zipcode in chapter.zips: s = helpers.stateforzip(zipcode, chapter.state) zipname = zipcode.split("|")[0] try: dataarr = zipindexdata[s] ind = helpers.findzipindex(dataarr, zipname) except KeyError: zipindexdata[s] = helpers.prepindexfile(domain + 'data/' + s + '/zip/simple.txt') ind = helpers.findzipindex(zipindexdata[s], zipname) if not isinstance(ind, str): #self.response.out.write(self.errorstr(ind)) ziperrors.append(zipcode) #return else: chapter.zipinds.append(ind + '|' + s) chapter.put() if len(ziperrors) == 0: self.redirect('/chapters') else: self.response.out.write(self.errorzips(ziperrors)) return
def post(self): #query database to see if this entry already exists (query by chaptername and state) domain = 'http://jandj.gldnfleece.com/' if self.request.get('chapterkey'): chapter = models.getchapter(self.request.get('chapterkey')) else: region = models.getregionfromstate(self.request.get('chapterstate').upper()) if region: chapter = models.Chapter(parent=region.key()) else: chapter = models.Chapter() zips = self.request.get('chapterzips') counties = self.request.get('chaptercounties') chapter.name = self.request.get('chaptername') chapter.state = self.request.get('chapterstate').upper() if zips: chapter.zips = map(helpers.mapstrip, zips.split(",")) else: chapter.zips = [] if counties: chapter.counties = map(helpers.mapstrip, counties.split(",")) else: chapter.counties = [] countyindexdata = {} chapter.countyinds = [] for county in chapter.counties: s = helpers.stateforcounty(county, chapter.state) countyname = county.split("|")[0] try: dataarr = countyindexdata[s] ind = helpers.findcountyindex(dataarr, countyname) except KeyError: #add dataarr to dict of state data arrays countyindexdata[s] = helpers.prepindexfile(domain + 'data/' + s + '/county/simple.txt') ind = helpers.findcountyindex(countyindexdata[s], countyname) if not isinstance(ind,str): self.response.out.write(self.errorstr(ind)) return chapter.countyinds.append(ind+'|'+s) zipindexdata = {} chapter.zipinds = [] ziperrors = [] for zipcode in chapter.zips: s = helpers.stateforzip(zipcode,chapter.state) zipname = zipcode.split("|")[0] try: dataarr = zipindexdata[s] ind = helpers.findzipindex(dataarr,zipname) except KeyError: zipindexdata[s] = helpers.prepindexfile(domain + 'data/' + s + '/zip/simple.txt') ind = helpers.findzipindex(zipindexdata[s], zipname) if not isinstance(ind,str): #self.response.out.write(self.errorstr(ind)) ziperrors.append(zipcode) #return else: chapter.zipinds.append(ind+'|'+s) chapter.put() if len(ziperrors) == 0: self.redirect('/chapters') else: self.response.out.write(self.errorzips(ziperrors)) return