Before this refactor, web_handlers.py has a lot of code duplication.
1. Code Duplication: Nine handler classes (e.g., PostHandler, ExistsHandler) duplicate the same state assignment logic in their initialize(self, app) methods. Six handlers share these exact 6 lines, and 3 use a subset:
self.state = app.state
self.subs = app.subs
self.sources = app.sources
self.port = app.port
self.env_path = app.env_path
self.login_enabled = app.login_enabled
2. Maintenance Risk: Adding a new shared property (e.g., self.logger = app.logger) requires manually updating 9 separate classes. Missing one will cause route-specific runtime AttributeError.
3. Proposed Solution: Since all 9 subclasses inherit from BaseHandler, this shared initialization logic should be moved into the parent class.
Before this refactor,
web_handlers.pyhas a lot of code duplication.1. Code Duplication: Nine handler classes (e.g.,
PostHandler,ExistsHandler) duplicate the same state assignment logic in theirinitialize(self, app)methods. Six handlers share these exact 6 lines, and 3 use a subset:2. Maintenance Risk: Adding a new shared property (e.g.,
self.logger = app.logger) requires manually updating 9 separate classes. Missing one will cause route-specific runtimeAttributeError.3. Proposed Solution: Since all 9 subclasses inherit from
BaseHandler, this shared initialization logic should be moved into the parent class.