home · contact · privacy
Minor HTTP handler refactoring.
authorChristian Heller <c.heller@plomlompom.de>
Sat, 18 May 2024 03:44:41 +0000 (05:44 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Sat, 18 May 2024 03:44:41 +0000 (05:44 +0200)
plomtask/http.py

index 88725fcc57b9ada06d2bb85a4744b489a8bf97e7..d5da1d7e4d914a17b2a27a67e80db762e83f8403 100644 (file)
@@ -94,11 +94,7 @@ class TaskHandler(BaseHTTPRequestHandler):
         """Handle any GET request."""
         try:
             self._init_handling()
-            if self.site in {'calendar', 'day', 'process', 'process_titles',
-                             'process_descriptions', 'process_efforts',
-                             'processes', 'todo', 'condition',
-                             'condition_titles', 'condition_descriptions',
-                             'conditions'}:
+            if hasattr(self, f'do_GET_{self.site}'):
                 template = f'{self.site}.html'
                 ctx = getattr(self, f'do_GET_{self.site}')()
                 html = self.server.jinja.get_template(template).render(**ctx)
@@ -211,7 +207,7 @@ class TaskHandler(BaseHTTPRequestHandler):
             postvars = parse_qs(self.rfile.read(length).decode(),
                                 keep_blank_values=True, strict_parsing=True)
             self.form_data = InputsParser(postvars)
-            if self.site in ('day', 'process', 'todo', 'condition'):
+            if hasattr(self, f'do_POST_{self.site}'):
                 redir_target = getattr(self, f'do_POST_{self.site}')()
                 self.conn.commit()
             else: