Commit cd6aed4f authored by Vincent Pelletier's avatar Vincent Pelletier

Fix PortalTransform's usage of volatile attributes.

parent e8667573
...@@ -142,6 +142,10 @@ class Transform(SimpleItem): ...@@ -142,6 +142,10 @@ class Transform(SimpleItem):
return transform return transform
def _load_transform(self): def _load_transform(self):
try:
return self._v_transform
except AttributeError:
pass
try: try:
m = import_from_name(self.module) m = import_from_name(self.module)
except ImportError, err: except ImportError, err:
...@@ -179,16 +183,12 @@ class Transform(SimpleItem): ...@@ -179,16 +183,12 @@ class Transform(SimpleItem):
security.declarePublic('get_documentation') security.declarePublic('get_documentation')
def get_documentation(self): def get_documentation(self):
""" return transform documentation """ """ return transform documentation """
if not hasattr(self, '_v_transform'): return self._load_transform().__doc__
self._load_transform()
return self._v_transform.__doc__
security.declarePrivate('convert') security.declarePrivate('convert')
def convert(self, *args, **kwargs): def convert(self, *args, **kwargs):
""" return apply the transform and return the result """ """ return apply the transform and return the result """
if not hasattr(self, '_v_transform'): return self._load_transform().convert(*args, **kwargs)
self._load_transform()
return self._v_transform.convert(*args, **kwargs)
security.declarePublic('name') security.declarePublic('name')
def name(self): def name(self):
...@@ -198,11 +198,7 @@ class Transform(SimpleItem): ...@@ -198,11 +198,7 @@ class Transform(SimpleItem):
security.declareProtected(ManagePortal, 'get_parameters') security.declareProtected(ManagePortal, 'get_parameters')
def get_parameters(self): def get_parameters(self):
""" get transform's parameters names """ """ get transform's parameters names """
if not hasattr(self, '_v_transform'): return sorted(self._load_transform().config.keys())
self._load_transform()
keys = self._v_transform.config.keys()
keys.sort()
return keys
security.declareProtected(ManagePortal, 'get_parameter_value') security.declareProtected(ManagePortal, 'get_parameter_value')
def get_parameter_value(self, key): def get_parameter_value(self, key):
...@@ -253,10 +249,9 @@ class Transform(SimpleItem): ...@@ -253,10 +249,9 @@ class Transform(SimpleItem):
# need to remap transform if necessary (i.e. configurable inputs / output) # need to remap transform if necessary (i.e. configurable inputs / output)
if kwargs.has_key('inputs') or kwargs.has_key('output'): if kwargs.has_key('inputs') or kwargs.has_key('output'):
tr_tool._unmapTransform(self) tr_tool._unmapTransform(self)
if not hasattr(self, '_v_transform'): transform = self._load_transform()
self._load_transform() self.inputs = kwargs.get('inputs', transform.inputs)
self.inputs = kwargs.get('inputs', self._v_transform.inputs) self.output = kwargs.get('output', transform.output)
self.output = kwargs.get('output', self._v_transform.output)
tr_tool._mapTransform(self) tr_tool._mapTransform(self)
# track output encoding # track output encoding
if kwargs.has_key('output_encoding'): if kwargs.has_key('output_encoding'):
......
...@@ -33,9 +33,11 @@ class Cache: ...@@ -33,9 +33,11 @@ class Cache:
return return
obj = self.obj obj = self.obj
key = self._genCacheKey(key) key = self._genCacheKey(key)
if getattr(aq_base(obj), self._id, None) is None: entry = getattr(aq_base(obj), self._id, None)
setattr(obj, self._id, {}) if entry is None:
getattr(obj, self._id)[key] = (time(), value) entry = {}
setattr(obj, self._id, entry)
entry[key] = (time(), value)
return key return key
def getCache(self, key): def getCache(self, key):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment