SourceColumn label optimization

Compute the SourceColumn at definition instead of doing it
during the resolve method. This move the label calculation
from the rendering to the startup.

Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2018-12-21 23:53:17 -04:00
parent 14f31d5614
commit b79c168dab

View File

@@ -537,9 +537,11 @@ class SourceColumn(object):
self.is_identifier = is_identifier
self.__class__._registry.setdefault(source, [])
self.__class__._registry[source].append(self)
self.label = None
@property
def label(self):
self._calculate_label()
def _calculate_label(self):
if not self._label:
if self.attribute:
name, model = SourceColumn.get_attribute_recursive(
@@ -551,7 +553,7 @@ class SourceColumn(object):
else:
self._label = 'Function'
return self._label
self.label = self._label
def resolve(self, context):
if self.attribute: