First of all, this isn't bothersome. I need real-life examples and use cases of problems people are solving, or this framework doesn't really mean much.
Now to address your question at hand: the way I see things, aspects are typically used to intercept the mainline code and then do a job. I admit it is tricky wrapping my head around what you are trying to do. But, what may be tricky is wrapping my head around "how" you are proposing to do it.
Based on your comments, you want to somehow store the results. Now, I may not be answering "how" you want to do it, but assuming persistence of some type is the question at hand, this is how I would go about it. I suggest injecting your aspect with the task to do, instead of wrapping it with another layer. This seems simpler to me, and requires less smarts about the the actual framework. I'm afraid that to wrap the wrapper, you are forcing yourself to understand more and more how it actually does its job, which takes you away from your game code.
Code:
class CommentatorCharacterObserver(MethodInterceptor):
def __init__(self, storage_strategy=None):
self.storage_strategy = storage_strategy
def invoke(self, invocation):
results = invocation.proceed()
self.storage_strategy.store(invocation, results)
return results
class Storage(object):
def store(self, invocation, results):
print "This would be the place to store the information somewhere, such as in a database (using DatabaseTemplate of course!)"
If I remember where you were plugging this in:
Code:
c = ProxyFactoryComponent(target = Character(Circle(Constants.radius), brain), interceptors = tagAdvisor)
It seems you want to observe things happening to Character objects. How about this?
Code:
class CharacterObserver(MethodInterceptor):
def __init__(self, storage_strategy=None):
self.storage_strategy = storage_strategy
def invoke(self, invocation):
results = invocation.proceed()
self.storage_strategy.store(invocation, results)
return results
class Storage(object):
def store(self, invocation, results):
print "LOG: ACTION=%s INSTANCE=%s RESULTS=%s" % (invocation.method_name, invocation.instance, str(results))
# Plug this in to where you construct the Character object
tagAdvisor = CharacterObserver(storage_strategy=Storage()) # This is an aspect with a plugged-in behavior
pointcutAdvisor = RegexpMethodPointcutAdvisor(advice = [tagAdvisor], patterns = [".*"])
c = ProxyFactoryComponent(target = Character(Circle(Constants.radius), brain), interceptors = pointcutAdvisor)
Some more tweaks to your storage strategy, and you can track the time it happened, what arguments are tied to that instance, anything! And you don't have to dig into the framework, but instead can focus on your game code.