Closed kaplun closed 8 years ago
@kaplun have you tried something like:
def execute_after_A_and_B(self, key, value):
if self.get('A') and self.get('B')
self['C'] = self.pop('A'), self.pop('B')
overdo = dojson.Overdo()
@overdo.over('a', 'A')
def match(self, key, value):
self['A'] = True
return execute_after_A_and_B(self, key, value)
@overdo.over('b', 'B')
def match(self, key, value):
self['B'] = True
return execute_after_A_and_B(self, key, value)
@jirikuncar I thought about something similar, but isn't it making writing rules more complex?
E.g. compare with:
@overdo.over('a', 'A')
def match(self, key, value):
if 'B' in self['__original_blob__']:
# B is there then...
else:
# B is not there then ...
@kaplun the complexity seems similar. One has to understand that there is a dependency between fields and execute_after_A_and_B
makes it IMHO more explicit.
@kaplun @jacquerie Shall I deduce from your thumbs-up that @jirikuncar's proposal works well for you? If so, let's close this issue.
P.S. Personally to me it looks much cleaner to use a execute_after_...
technique rather than introducing blobs and using conditions for Bs that weren't explicitly specified in overdo...
We worked around this issue using the approach outlined in https://github.com/inveniosoftware/dojson/issues/173#issuecomment-247542655.
When a rule based on a key A depends on the outcome of the execution of a rule based on a key B, then A depends on B. Currently there is no way to implement this.
I'd propose that the original object is passed inside
self
in a special key that is subsequently deleted.