Module: check_mk
Branch: master
Commit: 7ceb461f2f9a506300c38337204934bf97a01b8b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7ceb461f2f9a50…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Fri Apr 13 11:43:00 2018 +0200
Make the classes ModeEditCustomAttr and ModeCustomAttr abstract
Change-Id: I0ea2075e07909e1c86d44204544a40ecbab55093
---
web/htdocs/wato.py | 70 +++++++++++++++++++++++++++++++-----------------------
1 file changed, 40 insertions(+), 30 deletions(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 5cd28ef..2ac9a31 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -79,6 +79,7 @@
# | Importing, Permissions, global variables |
# `----------------------------------------------------------------------'
+import abc
import ast
import base64
import csv
@@ -15600,20 +15601,16 @@ def custom_attr_types():
class ModeEditCustomAttr(WatoMode):
+ __metaclass__ = abc.ABCMeta
+
def __init__(self):
+ # Note: the base class calls _from_vars
super(ModeEditCustomAttr, self).__init__()
@property
- def _type(self):
- raise NotImplementedError()
-
- @property
def _attrs(self):
return self._all_attrs[self._type]
- def _update_config(self):
- raise NotImplementedError()
-
def _from_vars(self):
self._name = html.var("edit") # missing -> new custom attr
self._new = self._name == None
@@ -15632,12 +15629,40 @@ class ModeEditCustomAttr(WatoMode):
else:
self._attr = {}
+ @abc.abstractproperty
+ def _type(self):
+ raise NotImplementedError()
+
+ @abc.abstractproperty
+ def _topics(self):
+ raise NotImplementedError()
+
+ @abc.abstractproperty
+ def _default_topic(self):
+ raise NotImplementedError()
+
+ @abc.abstractproperty
+ def _macro_help(self):
+ raise NotImplementedError()
+
+ @abc.abstractproperty
+ def _macro_label(self):
+ raise NotImplementedError()
+
+ @abc.abstractmethod
+ def _update_config(self):
+ raise NotImplementedError()
+
+ @abc.abstractmethod
def title(self):
raise NotImplementedError()
def _add_extra_attrs_from_html_vars(self):
pass
+ def _add_extra_form_sections(self):
+ pass
+
def action(self):
# TODO: remove subclass specific things specifict things (everything with _type
== 'user')
if not html.check_transaction():
@@ -15695,25 +15720,6 @@ class ModeEditCustomAttr(WatoMode):
return self._type + "_attrs"
- @property
- def _topics(self):
- raise NotImplementedError()
-
- @property
- def _default_topic(self):
- raise NotImplementedError()
-
- @property
- def _macro_help(self):
- raise NotImplementedError()
-
- @property
- def _macro_label(self):
- raise NotImplementedError()
-
- def _add_extra_form_sections(self):
- pass
-
def page(self):
# TODO: remove subclass specific things specifict things (everything with _type
== 'user')
html.begin_form("attr")
@@ -15864,6 +15870,8 @@ class ModeEditCustomHostAttr(ModeEditCustomAttr):
class ModeCustomAttrs(WatoMode):
+ __metaclass__ = abc.ABCMeta
+
def __init__(self):
super(ModeCustomAttrs, self).__init__()
# TODO: Inappropriate Intimacy: custom host attributes should not now about
@@ -15872,16 +15880,18 @@ class ModeCustomAttrs(WatoMode):
self._all_attrs = load_custom_attrs_from_mk_file(lock=html.is_transaction())
@property
- def _type(self):
- raise NotImplementedError()
-
- @property
def _attrs(self):
return self._all_attrs[self._type]
+ @abc.abstractproperty
+ def _type(self):
+ raise NotImplementedError()
+
+ @abc.abstractmethod
def title(self):
raise NotImplementedError()
+ @abc.abstractmethod
def _update_config(self):
raise NotImplementedError()