From 54ecab7590f857a07ec88039a9a68d98506b5529 Mon Sep 17 00:00:00 2001 From: Josh Wright Date: Sat, 14 May 2016 18:02:43 -0400 Subject: [PATCH] Improve view registration comments Clarify that HomeAssistantWSGI.register_view() can handle either instantiated or uninstantiated view classes. --- homeassistant/components/http.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/http.py b/homeassistant/components/http.py index df1b043ce0b..f7d778dd057 100644 --- a/homeassistant/components/http.py +++ b/homeassistant/components/http.py @@ -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