Commit aac2c5a4 authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: There is no need for `description` and `source_reference` to...

ZODB Components: There is no need for `description` and `source_reference` to be RecordedProperties.

* Not considered for `modified` state (dynamic_class_generation_interaction_workflow).
* `source_reference` sets only once at import from filesystem.
parent 9ee53625
...@@ -83,35 +83,37 @@ class RecordablePropertyMetaClass(ExtensionClass): ...@@ -83,35 +83,37 @@ class RecordablePropertyMetaClass(ExtensionClass):
def getterWrapper(accessor_name, property_name, property_getter): def getterWrapper(accessor_name, property_name, property_getter):
dictionary['security'].declareProtected(Permissions.AccessContentsInformation, dictionary['security'].declareProtected(Permissions.AccessContentsInformation,
accessor_name) accessor_name)
if property_name in dictionary['_recorded_property_name_set']:
def getter(self, validated_only=False): def getter(self, validated_only=False):
""" """
When validated_only is True, then returns the property recorded if When validated_only is True, then returns the property recorded if
the Component has been modified but there was an error upon the Component has been modified but there was an error upon
consistency checking consistency checking
""" """
if validated_only: if validated_only:
try: try:
return self.getRecordedProperty(property_name) return self.getRecordedProperty(property_name)
# AttributeError when this property has never been recorded before # AttributeError when this property has never been recorded before
# (_recorded_property_dict) and KeyError if the property has been # (_recorded_property_dict) and KeyError if the property has been
# recorded before but is not anymore # recorded before but is not anymore
except (AttributeError, KeyError): except (AttributeError, KeyError):
pass pass
return property_getter(self) return property_getter(self)
else:
getter = property_getter
getter.__name__ = accessor_name getter.__name__ = accessor_name
return getter return getter
for (property_name, for (property_name,
property_getter) in dictionary['_recorded_property_name_getter_dict'].iteritems(): property_getter) in dictionary['_property_name_getter_dict'].iteritems():
setter_name = '_set' + convertToUpperCase(property_name)
dictionary[setter_name] = setterWrapper(setter_name, property_name)
getter_name = 'get' + convertToUpperCase(property_name) getter_name = 'get' + convertToUpperCase(property_name)
dictionary[getter_name] = getterWrapper(getter_name, property_name, dictionary[getter_name] = getterWrapper(getter_name, property_name,
property_getter) property_getter)
if property_name in dictionary['_recorded_property_name_set']:
setter_name = '_set' + convertToUpperCase(property_name)
dictionary[setter_name] = setterWrapper(setter_name, property_name)
# docstring required for publishing any object # docstring required for publishing any object
dictionary['__doc__'] = metacls.__doc__ dictionary['__doc__'] = metacls.__doc__
...@@ -163,7 +165,11 @@ class ComponentMixin(PropertyRecordableMixin, Base): ...@@ -163,7 +165,11 @@ class ComponentMixin(PropertyRecordableMixin, Base):
'TextDocument', 'TextDocument',
'Component') 'Component')
_recorded_property_name_getter_dict = { _recorded_property_name_set = {'reference',
'version',
'text_content'}
_property_name_getter_dict = {
'reference': BaseAccessor.Getter('getReference', 'reference': BaseAccessor.Getter('getReference',
'reference', 'reference',
'string', 'string',
...@@ -302,7 +308,7 @@ class ComponentMixin(PropertyRecordableMixin, Base): ...@@ -302,7 +308,7 @@ class ComponentMixin(PropertyRecordableMixin, Base):
reference, version and text_content reference, version and text_content
""" """
if not self.checkConsistency(): if not self.checkConsistency():
for property_name in self._recorded_property_name_getter_dict: for property_name in self._recorded_property_name_set:
self.clearRecordedProperty(property_name) self.clearRecordedProperty(property_name)
self.validate() self.validate()
......
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