From: Christian Heller Date: Sat, 18 May 2024 03:44:41 +0000 (+0200) Subject: Minor HTTP handler refactoring. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/%7B%7B%20web_path%20%7D%7D/%7B%7Bprefix%7D%7D/day_todos?a=commitdiff_plain;h=ce9b74158c87750ccf1c8f363a59c0465e4b1277;p=plomtask Minor HTTP handler refactoring. --- diff --git a/plomtask/http.py b/plomtask/http.py index 88725fc..d5da1d7 100644 --- a/plomtask/http.py +++ b/plomtask/http.py @@ -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: