huge use of weakrefs to remove memoryleaks due to circular references
This commit is contained in:
@ -22,6 +22,7 @@
|
||||
# ____________________________________________________________
|
||||
from time import time
|
||||
from copy import copy
|
||||
import weakref
|
||||
from tiramisu.error import (RequirementError, PropertiesOptionError,
|
||||
ConstError, ConfigError)
|
||||
from tiramisu.i18n import _
|
||||
@ -253,7 +254,7 @@ class Settings(object):
|
||||
"""
|
||||
# generic owner
|
||||
self._owner = owners.user
|
||||
self.context = context
|
||||
self.context = weakref.ref(context)
|
||||
import_lib = 'tiramisu.storage.{0}.setting'.format(storage.storage)
|
||||
self._p_ = __import__(import_lib, globals(), locals(), ['Settings'],
|
||||
-1).Settings(storage)
|
||||
@ -287,7 +288,7 @@ class Settings(object):
|
||||
if opt is not None and _path is None:
|
||||
_path = self._get_opt_path(opt)
|
||||
self._p_.reset_properties(_path)
|
||||
self.context.cfgimpl_reset_cache()
|
||||
self.context().cfgimpl_reset_cache()
|
||||
|
||||
def _getproperties(self, opt=None, path=None, is_apply_req=True):
|
||||
if opt is None:
|
||||
@ -337,7 +338,7 @@ class Settings(object):
|
||||
self._p_.reset_properties(path)
|
||||
else:
|
||||
self._p_.setproperties(path, properties)
|
||||
self.context.cfgimpl_reset_cache()
|
||||
self.context().cfgimpl_reset_cache()
|
||||
|
||||
#____________________________________________________________
|
||||
def validate_properties(self, opt_or_descr, is_descr, is_write, path,
|
||||
@ -377,7 +378,7 @@ class Settings(object):
|
||||
properties -= frozenset(('mandatory', 'frozen'))
|
||||
else:
|
||||
if 'mandatory' in properties and \
|
||||
not self.context.cfgimpl_get_values()._isempty(
|
||||
not self.context().cfgimpl_get_values()._isempty(
|
||||
opt_or_descr, value):
|
||||
properties.remove('mandatory')
|
||||
if is_write and 'everything_frozen' in self_properties:
|
||||
@ -494,7 +495,7 @@ class Settings(object):
|
||||
" '{0}' with requirement on: "
|
||||
"'{1}'").format(path, reqpath))
|
||||
try:
|
||||
value = self.context._getattr(reqpath,
|
||||
value = self.context()._getattr(reqpath,
|
||||
force_permissive=True)
|
||||
except PropertiesOptionError, err:
|
||||
if not transitive:
|
||||
@ -519,4 +520,4 @@ class Settings(object):
|
||||
return calc_properties
|
||||
|
||||
def _get_opt_path(self, opt):
|
||||
return self.context.cfgimpl_get_description().impl_get_path_by_opt(opt)
|
||||
return self.context().cfgimpl_get_description().impl_get_path_by_opt(opt)
|
||||
|
Reference in New Issue
Block a user