Module: check_mk
Branch: master
Commit: de45e622d6b28cd6c45c822201adefe0e0dbf247
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=de45e622d6b28c…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Feb 17 16:34:50 2016 +0100
watolib: Cleaned up missing but referenced methods/attributes in abstract classes
---
web/htdocs/watolib.py | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index b74ebd2..d689ec0 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -316,6 +316,10 @@ class WithPermissions(object):
return self.reason_why_user_may_not(config.user_id, how)
+ def user_needs_permission(self, user_id, how):
+ raise NotImplementedError("Subclasses has to implement this!")
+
+
def need_permission(self, how):
self.user_needs_permission(config.user_id, how)
@@ -342,6 +346,7 @@ class WithPermissions(object):
class WithPermissionsAndAttributes(WithPermissions):
def __init__(self):
WithPermissions.__init__(self)
+ self._attributes = {}
# .--------------------------------------------------------------------.
# | ATTRIBUTES |
@@ -363,6 +368,10 @@ class WithPermissionsAndAttributes(WithPermissions):
return attrname in self.attributes()
+ def effective_attributes(self):
+ raise NotImplementedError("Subclasses has to implement this!")
+
+
def effective_attribute(self, attrname, default_value=None):
return self.effective_attributes().get(attrname, default_value)
@@ -387,6 +396,10 @@ class BaseFolder(WithPermissionsAndAttributes):
WithPermissions.__init__(self)
+ def hosts(self):
+ raise NotImplementedError("Subclasses has to implement this!")
+
+
def host_names(self):
return self.hosts().keys()
@@ -403,13 +416,6 @@ class BaseFolder(WithPermissionsAndAttributes):
return len(self.hosts()) != 0
- def num_hosts_recursively(self):
- num = self.num_hosts()
- for subfolder in self.subfolders().values():
- num += subfolder.num_hosts_recursively()
- return num
-
-
def host_validation_errors(self):
return validate_all_hosts(self.host_names())
@@ -1059,6 +1065,13 @@ class Folder(BaseFolder):
return self._num_hosts
+ def num_hosts_recursively(self):
+ num = self.num_hosts()
+ for subfolder in self.subfolders().values():
+ num += subfolder.num_hosts_recursively()
+ return num
+
+
def all_hosts_recursively(self):
hosts = {}
hosts.update(self.hosts())