summaryrefslogtreecommitdiffstats
path: root/cobbler/collection.py
diff options
context:
space:
mode:
Diffstat (limited to 'cobbler/collection.py')
-rw-r--r--cobbler/collection.py41
1 files changed, 21 insertions, 20 deletions
diff --git a/cobbler/collection.py b/cobbler/collection.py
index c02d10c..3d44510 100644
--- a/cobbler/collection.py
+++ b/cobbler/collection.py
@@ -1,29 +1,30 @@
+"""
+Base class for any serializable list of things...
+
+Michael DeHaan <mdehaan@redhat.com>
+"""
+
import serializable
import utils
import msg
-"""
-Base class for any serializable lists of things...
-"""
class Collection(serializable.Serializable):
- def factory_produce(self):
- raise exceptions.NotImplementedError
-
- def filename(self):
- raise exceptions.NotImplementedError
-
def __init__(self,config):
"""
Constructor.
"""
self.config = config
- self.debug = 1
self.clear()
+ def factory_produce(self):
+ raise exceptions.NotImplementedError
+
+ def filename(self):
+ raise exceptions.NotImplementedError
def clear(self):
- if self.debug:
+ if utils.app_debug:
print "Collection::clear"
self.listing = {}
@@ -32,7 +33,7 @@ class Collection(serializable.Serializable):
Return anything named 'name' in the collection, else return None if
no objects can be found.
"""
- if self.debug:
+ if utils.app_debug:
print "Collection::find(%s)" % name
if name in self.listing.keys():
return self.listing[name]
@@ -43,20 +44,20 @@ class Collection(serializable.Serializable):
"""
Serialize the collection
"""
- if self.debug:
+ if utils.app_debug:
print "Collection::to_datastruct"
datastruct = [x.to_datastruct() for x in self.listing.values()]
return datastruct
def from_datastruct(self,datastruct):
- if self.debug:
+ if utils.app_debug:
print "Collection::from_datastruct(%s)" % datastruct
if datastruct is None:
print "DEBUG: from_datastruct -> None, skipping"
return
print "DEBUG: from_datastruct: %s" % datastruct
- for x in datastruct:
- item = self.factory_produce(self.config)
+ for seed_data in datastruct:
+ item = self.factory_produce(self.config,seed_data)
self.add(item)
def add(self,ref):
@@ -66,7 +67,7 @@ class Collection(serializable.Serializable):
object specified by ref deems itself invalid (and therefore
won't be added to the collection).
"""
- if self.debug:
+ if utils.app_debug:
print "Collection::add(%s)" % ref
if ref is None or not ref.is_valid():
if utils.last_error() is None or utils.last_error() == "":
@@ -82,7 +83,7 @@ class Collection(serializable.Serializable):
for reading by humans or parsing from scripts. Actually scripts
would be better off reading the YAML in the config files directly.
"""
- if self.debug:
+ if utils.app_debug:
print "Collection::printable"
values = map(lambda(a): a.printable(), sorted(self.listing.values()))
if len(values) > 0:
@@ -94,7 +95,7 @@ class Collection(serializable.Serializable):
"""
Iterator for the collection. Allows list comprehensions, etc
"""
- if self.debug:
+ if utils.app_debug:
print "Collection::__iter__"
for a in self.listing.values():
yield a
@@ -103,7 +104,7 @@ class Collection(serializable.Serializable):
"""
Returns size of the collection
"""
- if self.debug:
+ if utils.app_debug:
print "Collection::__len__"
return len(self.listing.values())