Example #1
0
 def get_beer_or_bust(self, beer_id):
     beer = Beer.get_by_key_name(beer_id)
     if not beer:
        beer = Beer.get(beer_id)
     if not beer:
        raise webob.exc.HTTPNotFound()
     return beer
Example #2
0
    def post(self):
       name = self.request.params['name']
       description = self.request.params['description']
       style = self.request.params['style']
       abv = float(self.request.params['abv'])
       brewery = self.request.params['brewery']
       if Beer.get_by_key_name(name):
          raise Conflict(name, webapp2.uri_for('beer', beer_id=name))
       new_beer = Beer(key_name=name, style=style, abv=abv, description=description,
				brewery=brewery)
       if 'vintage' in self.request.params:
          new_beer.vintage = int(self.request.get('vintage'))
       if 'photo_url' in self.request.params:
          new_beer.photo_url = photo_url
       new_beer.put()
       webapp2.redirect_to('beer', beer_id=name)