docs: def region(request, abbr):
      '''
      Context:
          - abbr
          - metadata
          - sessions
          - chambers
          - joint_committee_count
          - geo_bounds
          - nav_active
  
      Templates:
          - bill/web/public/region.html
      '''
      report = db.reports.find_one({'_id': abbr})
      try:
          meta = Metadata.get_object(abbr)
      except DoesNotExist:
          raise Http404
  
      fallback_bounds = GEO_BOUNDS['US']
      geo_bounds = GEO_BOUNDS.get(abbr.upper(), fallback_bounds)
  
      # count legislators
      legislators = meta.legislators({'active': True}, {'party': True,
                                                        'chamber': True})
      # Maybe later, mapreduce instead?
      party_counts = defaultdict(lambda: defaultdict(int))
      for leg in legislators:
          if 'chamber' in leg:    # exclude lt. governors
              party_counts[leg['chamber']][leg['party']] += 1
  
      chambers = []
  
      for chamber_type, chamber in meta['chambers'].items():
          res = {}
  
          # chamber metadata
          res['type'] = chamber_type
          res['title'] = chamber['title']
          res['name'] = chamber['name']
  
          # legislators
          res['legislators'] = {
              'count': sum(party_counts[chamber_type].values()),
              'party_counts': dict(party_counts[chamber_type]),
          }
  
          # committees
          res['committees_count'] = meta.committees({'chamber': chamber_type}
                                                   ).count()
  
          res['latest_bills'] = meta.bills({'chamber': chamber_type}).sort(
              [('action_dates.first', -1)]).limit(2)
          res['passed_bills'] = meta.bills({'chamber': chamber_type}).sort(
              [('action_dates.passed_' + chamber_type, -1)]).limit(2)
  
          chambers.append(res)
  
      joint_committee_count = meta.committees({'chamber': 'joint'}).count()
  
      # add bill counts to session listing
      sessions = meta.sessions()
      for s in sessions:
          try:
              s['bill_count'] = (
                  report['bills']['sessions'][s['id']]['upper_count']
                  + report['bills']['sessions'][s['id']]['lower_count'])
          except KeyError:
              # there's a chance that the session had no bills
              s['bill_count'] = 0
  
      return render(request, templatename('region'),
                    dict(abbr=abbr, metadata=meta, sessions=sessions,
                         chambers=chambers,
                         joint_committee_count=joint_committee_count,
                         geo_bounds=geo_bounds,
                         nav_active='home'))