Skip to content

duplicate handler initializations in web_handler #1354

@tonypzy

Description

@tonypzy

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions