示例#1
0
 def GET(self, district, format=None):
     try:
         district = district.upper()
         d = db.select(['district', 'state', 'politician'],
                       what=('district.*, '
                             'state.name as state_name, '
                             'politician.firstname as pol_firstname, '
                             'politician.lastname as pol_lastname, '
                             'politician.id as pol_id, '
                             'politician.photo_path as pol_photo_path'),
                       where=('district.name = $district AND '
                              'district.state = state.code AND '
                              'politician.district = district.name'),
                       vars=locals())[0]
     except IndexError:
         raise web.notfound
     
     out = apipublish.publish({
       'uri': 'http://watchdog.net/us/' + district.lower(),
       'type': 'District',
       'state': apipublish.URI('http://watchdog.net/us/' + d.state.lower()),
       'wikipedia almanac': apipublish.URI,
       'name voting area_sqmi cook_index poverty_pct median_income '
       'est_population est_population_year outline center_lat '
       'center_lng zoom_level': apipublish.identity,
     }, [d], format)
     if out is not False:
         return out
     
     if d.district == 0:
         d.districtth = 'at-large'
     else:
         d.districtth = web.nthstr(d.district)
     
     return render.district(d)
示例#2
0
 def districtth(self):
     if self.district == 0:
         return "at-large"
     else:
         return web.nthstr(self.district)
示例#3
0
 def districtth(self):
     if self.district == 0:
         return 'at-large'
     else:
         return web.nthstr(self.district)