def editRestaurant(restaurant_id):
    #item to edit
    editedRestaurant = RestaurantQuery.get_restaurant(restaurant_id)
    #if posted too, process the form
    #else just display the page and it's form
    if request.method == 'POST':
        if request.form['name']:
            editedRestaurant.name = request.form['name']
        RestaurantQuery.edit_restaurant(editedRestaurant.name, editedRestaurant.id)

        #flash message
        flash("Updated "+editedRestaurant.name)

        return redirect(url_for('restaurants'))
    else:
        
        return render_template('editRestaurant.html', restaurant_id=restaurant_id, item=editedRestaurant)
	def do_POST(self):
		try:
			#successful response
			self.send_response(301)
			self.end_headers()

			#read our data sent in.
			ctype, pdict = cgi.parse_header(self.headers.getheader('content-type'))

			#check for form data
			if ctype == 'multipart/form-data':

				#store the fields sent in
				fields = cgi.parse_multipart(self.rfile, pdict)
				try:
					name = fields.get('restaurant')
				except:
					pass

				#hidden field telling us which form is being sent
				operation = fields.get('operation')

				sucess_response = ''

				#determine our query based on which form was sent
				if operation[0] == 'add':
					#add our restaurant
					RestaurantQuery.add_restaurant(name[0])

					sucess_response = "<h1>successfully added new restaurant %s</h1>" % name[0]

				if operation[0] == 'edit':
					#get our id value, we stored it in a hidden field
					rID = fields.get('rID')	

					#update our restaurant
					RestaurantQuery.edit_restaurant(int(rID[0]), name[0])

					sucess_response = "<h1>successfully edited %s</h1>" % name[0]

				if operation[0] == 'delete':
					#get our id value, we stored it in a hidden field
					rID = fields.get('rID')

					#delete our restaurant
					rName = RestaurantQuery.delete_restaurant(int(rID[0]))

					sucess_response = "<h1>successfully deleted %s</h1>" % rName


			#output the response
			output = ""
			output += "<html><body>"
			output += sucess_response

			#link to make new restaurants
			output += "<a href='/restaurants/new'>Click here to add a new restaurant</a>"

			#create another query instance, now we'll get
			#our new restaurant in the list
			restaurants = RestaurantQuery.get_items(Restaurant)

			#append our query results to the message
			output += restaurants

			output += "</body></html>"
			self.wfile.write(output)
			print output
			return

		except:
			pass