예제 #1
0
 def add_hobby(self, request, response, pathmatch):
     person = Person(id=pathmatch.group('id'))
     hobby = unquote(pathmatch.group('hobby'))  # path parts aren't decoded by server framework
     if hobby not in person.get_hobbies():
         person.hobbies.append(hobby)
         person.store()
     response.send(code=200, body="")
예제 #2
0
 def delete_hobby(self, request, response, pathmatch):
     person = Person(id=pathmatch.group('id'))
     hobbies = person.get_hobbies()
     try:
         hobby = unquote(pathmatch.group('hobby'))  # path parts aren't decoded by server framework
         hobbies.remove(hobby)
         person.hobbies = hobbies
         person.store()
         response.send(code=200, body="")
     except ValueError:
         response.send(code=404, body="<p>Fehler: Hobby '{}' nicht gefunden.</p>".format(hobby))