示例#1
0
    def recv_add_recipe(self, environ, start_response):
        formdata = environ["QUERY_STRING"]
        results = urlparse.parse_qs(formdata)

        ingredients = []

        # add ingredients to the list
        for i in range(0, 5):
            try:
                ingValue = "".join(results["in" + str(i)])
                amtValue = "".join(results["amt" + str(i)])
                ing = (ingValue, amtValue)
                ingredients.append(ing)
            except KeyError:
                continue

        # create the new recipe
        r = drinkz.recipes.Recipe("".join(results["name"]), ingredients)

        try:
            drinkz.db.add_recipe(r)
        except drinkz.db.DuplicateRecipeName:
            pass

        # return to the recipe list page
        start_response("200 OK", list(html_headers))
        return page_builder.build_recipes()
示例#2
0
 def recipes(self, environ, start_response):
     start_response("200 OK", list(html_headers))
     return page_builder.build_recipes()