summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2006-05-05 12:08:23 -0400
committerJim Meyering <jim@meyering.net>2006-05-05 12:08:23 -0400
commit09da6bb67e890de6dc5ba2716c79b0446f861b55 (patch)
treeffe52a708e4b8c6fe8263790790c3a615b9a2274
parent82b03d49c9d5591f9d2f83bc5022703a21bda18a (diff)
downloadthird_party-cobbler-09da6bb67e890de6dc5ba2716c79b0446f861b55.tar.gz
third_party-cobbler-09da6bb67e890de6dc5ba2716c79b0446f861b55.tar.xz
third_party-cobbler-09da6bb67e890de6dc5ba2716c79b0446f861b55.zip
Weakref additions prior to refactoring
-rw-r--r--cobbler/check.py5
-rw-r--r--cobbler/config.py3
-rw-r--r--cobbler/sync.py3
-rw-r--r--cobbler/util.py6
-rw-r--r--tests/tests.py3
5 files changed, 12 insertions, 8 deletions
diff --git a/cobbler/check.py b/cobbler/check.py
index bd4137a..ce0fdaf 100644
--- a/cobbler/check.py
+++ b/cobbler/check.py
@@ -5,14 +5,15 @@
import os
import sys
import re
+import weakref
from msg import *
class BootCheck:
def __init__(self, api):
- self.api = api
- self.config = self.api.config
+ self.api = weakref.proxy(api)
+ self.config = weakref.proxy(self.api.config)
def run(self):
diff --git a/cobbler/config.py b/cobbler/config.py
index 197da91..ac08ca5 100644
--- a/cobbler/config.py
+++ b/cobbler/config.py
@@ -6,6 +6,7 @@
import api
import util
from msg import *
+import weakref
import syck # pysyck > 0.61, so it has dump()
import os
@@ -25,7 +26,7 @@ class BootConfig:
users of this class need to call deserialize() to load config
file values. See cobbler.py for how the CLI does it.
"""
- self.api = api
+ self.api = weakref.proxy(api)
self.settings_file = global_settings_file
self.state_file = global_state_file
self.set_defaults()
diff --git a/cobbler/sync.py b/cobbler/sync.py
index 3494382..f555b4f 100644
--- a/cobbler/sync.py
+++ b/cobbler/sync.py
@@ -12,6 +12,7 @@ import re
import shutil
import syck
import IPy
+import weakref
from msg import *
"""
@@ -21,7 +22,7 @@ Handles conversion of internal state to the tftpboot tree layout
class BootSync:
def __init__(self,api):
- self.api = api
+ self.api = weakref.proxy(api)
self.verbose = True
diff --git a/cobbler/util.py b/cobbler/util.py
index ae7dde7..3a4d852 100644
--- a/cobbler/util.py
+++ b/cobbler/util.py
@@ -8,12 +8,14 @@ import os
import re
import socket
import glob
+import weakref
class BootUtil:
def __init__(self,api,config):
- self.api = api
- self.config = config
+ # BootAPI is the preferred holder of all references
+ self.api = weakref.proxy(api)
+ self.config = weakref.proxy(config)
self.re_kernel = re.compile(r'vmlinuz-(\d+)\.(\d+)\.(\d+)-(.*)')
self.re_initrd = re.compile(r'initrd-(\d+)\.(\d+)\.(\d+)-(.*).img')
diff --git a/tests/tests.py b/tests/tests.py
index cfe1081..34b66d8 100644
--- a/tests/tests.py
+++ b/tests/tests.py
@@ -49,8 +49,7 @@ class BootTest(unittest.TestCase):
self.make_basic_config()
def tearDown(self):
- # this is causing problems with the sync() test
- # shutil.rmtree(self.topdir,ignore_errors=True)
+ shutil.rmtree(self.topdir,ignore_errors=True)
self.api = None
def make_basic_config(self):