From 09da6bb67e890de6dc5ba2716c79b0446f861b55 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Fri, 5 May 2006 12:08:23 -0400 Subject: Weakref additions prior to refactoring --- cobbler/check.py | 5 +++-- cobbler/config.py | 3 ++- cobbler/sync.py | 3 ++- cobbler/util.py | 6 ++++-- tests/tests.py | 3 +-- 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): -- cgit