def do_POST(self):
        try:
            self.send_response(301)
            self.end_headers()

            ctype, pdict = cgi.parse_header(
                self.headers.getheader('Content-type'))
            if ctype == 'multipart/form-data':
                fields = cgi.parse_multipart(self.rfile, pdict)
                print fields
                messagecontent = fields.get('message')

            if self.path.endswith("/restaurants/new"):
                db_anfragen.create_restaurant(messagecontent[0])
                output = header
                output += "<h3>Neues Restaurant erstellt: %s</h3>" % messagecontent[
                    0]
                output += "<h2>Möchtest Du ein weiteres Restaurant erstellen?</h2>"
                output += new_form + back + footer
                self.wfile.write(output)
            elif self.path.endswith("/delete"):
                restaurant_alt = db_anfragen.getRestaurant(messagecontent[0])
                alt = restaurant_alt.name.encode("utf-8")
                db_anfragen.deleteRestaurant(messagecontent[0])
                output = header
                output += '<h3>Restaurant "%s" gelöscht</h3>' % alt
                output += back
                self.wfile.write(output)
            if messagecontent[1]:
                restaurant_alt = db_anfragen.getRestaurant(messagecontent[1])
                alt = restaurant_alt.name.encode("utf-8")
                db_anfragen.updateRestaurant(messagecontent[0],
                                             messagecontent[1])
                output = header
                output += '<h3>Restaurant "%s" umbenannt in: %s</h3>' % (
                    alt, messagecontent[0])
                output += back
                self.wfile.write(output)
        except Exception, e:
            raise e
	def do_POST(self):
		try:
			self.send_response(301)
			self.end_headers()

			ctype, pdict = cgi.parse_header(
				self.headers.getheader('Content-type'))
			if ctype == 'multipart/form-data':
				fields = cgi.parse_multipart(self.rfile, pdict)
				print fields
				messagecontent = fields.get('message')

			if self.path.endswith("/restaurants/new"):
				db_anfragen.create_restaurant(messagecontent[0])
				output = header
				output += "<h3>Neues Restaurant erstellt: %s</h3>" % messagecontent[0]
				output += "<h2>Möchtest Du ein weiteres Restaurant erstellen?</h2>"
				output += new_form + back + footer
				self.wfile.write(output)
			elif self.path.endswith("/delete"):
				restaurant_alt = db_anfragen.getRestaurant(messagecontent[0])
				alt = restaurant_alt.name.encode("utf-8")
				db_anfragen.deleteRestaurant(messagecontent[0])
				output = header
				output += '<h3>Restaurant "%s" gelöscht</h3>' % alt
				output += back
				self.wfile.write(output)
			if messagecontent[1]:
				restaurant_alt = db_anfragen.getRestaurant(messagecontent[1])
				alt = restaurant_alt.name.encode("utf-8")
				db_anfragen.updateRestaurant(messagecontent[0], messagecontent[1])
				output = header
				output += '<h3>Restaurant "%s" umbenannt in: %s</h3>' % (alt,messagecontent[0])
				output += back
				self.wfile.write(output)
		except Exception, e:
			raise e
def getPathID(pfad):
	# Extract ID
	print pfad
	m = re.search(r'restaurants\/(\d+)\/', pfad)
	return db_anfragen.getRestaurant(int(m.group(1)))
def getPathID(pfad):
    # Extract ID
    print pfad
    m = re.search(r'restaurants\/(\d+)\/', pfad)
    return db_anfragen.getRestaurant(int(m.group(1)))