Module: check_mk
Branch: master
Commit: 7e3a87fb2fb256e4e69798de546e5a7d48e1cd1c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7e3a87fb2fb256…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Wed Apr 11 15:43:56 2018 +0200
Make _what an instance attribute for custom host/user attributes
Previously, _what was a class attribute defined in subclasses, but was
used already in the base classes. Now, _what is made an instance
attribute defined in the base class itself. This makes the use of _what
more explicit. This is sufficient to make pylint happy again.
In the long run _what has to be moved to the subclasses, because
base classes should not now implementation details of child classes.
Change-Id: I19edbe611a115aab26a28009e337981636b8e405
---
web/htdocs/wato.py | 32 +++++++++++++++++++++++++-------
1 file changed, 25 insertions(+), 7 deletions(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index d6adb02..1570cca 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -15522,6 +15522,15 @@ class ModePatternEditor(WatoMode):
# '----------------------------------------------------------------------'
class CustomAttrMode(WatoMode):
+ def __init__(self, what):
+ # TODO: move _what to the subclasses.
+ # Note: _what is used in _from_vars defined in the subclass
+ # ModeEditCustomAttr but called in the base class WatoMode.
+ # Therefore, we have to set it before init right now.
+ self._what = what
+ super(CustomAttrMode, self).__init__()
+
+
@classmethod
def custom_attr_types(cls):
return [
@@ -15572,6 +15581,10 @@ class CustomAttrMode(WatoMode):
class ModeEditCustomAttr(CustomAttrMode):
+ def __init__(self, what):
+ super(ModeEditCustomAttr, self).__init__(what)
+
+
def _from_vars(self):
self._name = html.var("edit") # missing -> new custom attr
self._new = self._name == None
@@ -15733,8 +15746,8 @@ class ModeEditCustomAttr(CustomAttrMode):
class ModeEditCustomUserAttr(ModeEditCustomAttr):
- # TODO: Cleanup "what" variable
- _what = "user"
+ def __init__(self):
+ super(ModeEditCustomUserAttr, self).__init__('user')
def title(self):
if self._new:
@@ -15749,7 +15762,8 @@ class ModeEditCustomUserAttr(ModeEditCustomAttr):
class ModeEditCustomHostAttr(ModeEditCustomAttr):
- _what = "host"
+ def __init__(self):
+ super(ModeEditCustomHostAttr, self).__init__('host')
def title(self):
if self._new:
@@ -15765,8 +15779,8 @@ class ModeEditCustomHostAttr(ModeEditCustomAttr):
class ModeCustomAttrs(CustomAttrMode):
- def __init__(self):
- super(ModeCustomAttrs, self).__init__()
+ def __init__(self, what):
+ super(ModeCustomAttrs, self).__init__(what)
self._load_attributes(lock=html.is_transaction())
@@ -15822,7 +15836,9 @@ class ModeCustomAttrs(CustomAttrMode):
class ModeCustomUserAttrs(ModeCustomAttrs):
- _what = "user"
+ def __init__(self):
+ super(ModeCustomUserAttrs, self).__init__('user')
+
def title(self):
return _("Custom User Attributes")
@@ -15835,7 +15851,9 @@ class ModeCustomUserAttrs(ModeCustomAttrs):
class ModeCustomHostAttrs(ModeCustomAttrs):
- _what = "host"
+ def __init__(self):
+ super(ModeCustomHostAttrs, self).__init__('host')
+
def title(self):
return _("Custom Host Attributes")