Grant Baillie wrote:
Sure. But how exactly would this work: i.e. onValueChanged(),
monitoring the changed values, or some other way? I'm a little wary of
onValueChanged() becoming overly complex. In general, we want to index
these attributes, so what I'd like to see is an API similar to what's
now pim.Calculated:
class MyContentItem(ContentItem):
def getInterestingDatetime(self):
# ... perform possibly complex calculation
return resultOfPossiblyComplexCalculation
# optional: setInterestingDatetime
interestingDatetime = schema.IndexedProperty(
schema.DateTime,
basedOn = ('startTime', 'ticklers'),
# basedOn == attributes in Indexed.addIndex()
indexType = 'attribute', # could be
'string',
fset = getInterestingDatetime)
This would create an attribute which is a property on the class, and
also create the appropriate index (named the same as the attribute).
Maybe it somehow caches the value so that getInterestingDatetime
doesn't get called every time the attribute is accessed (though it's
not clear that's necessary).
(FWIW, it's the index that ends up creating a monitor here to update
when changes are made to the "source" attribute).
I'm also not in favor of using onValueChanged.
A simple implementation possibility would be to use a python property
for each source attribute involved in the complex calculation. It would
set the source attribute and call the complex calculation method that
might update the indexed attribute.
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Open Source Applications Foundation "chandler-dev" mailing list
http://lists.osafoundation.org/mailman/listinfo/chandler-dev