mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Improve view registration comments
Clarify that HomeAssistantWSGI.register_view() can handle either instantiated or uninstantiated view classes.
This commit is contained in:
parent
15e329a588
commit
54ecab7590
@ -127,14 +127,16 @@ class HomeAssistantWSGI(object):
|
||||
def register_view(self, view):
|
||||
"""Register a view with the WSGI server.
|
||||
|
||||
The view argument must inherit from the HomeAssistantView class, and
|
||||
it must have (globally unique) 'url' and 'name' attributes.
|
||||
The view argument must be a class that inherits from HomeAssistantView.
|
||||
It is optional to instantiate it before registering; this method will
|
||||
handle it either way.
|
||||
"""
|
||||
from werkzeug.routing import Rule
|
||||
|
||||
if view.name in self.views:
|
||||
_LOGGER.warning("View '%s' is being overwritten", view.name)
|
||||
if isinstance(view, type):
|
||||
# Instantiate the view, if needed
|
||||
view = view(self.hass)
|
||||
|
||||
self.views[view.name] = view
|
||||
|
Loading…
x
Reference in New Issue
Block a user