OK, so now things are going really well, I have another (silly) question!
Can I *wrap* a wrapper?
Here's the class I want to wrap (simplified down):
and I'm wrapping with:Code:class CommentatorCharacterObserver(MethodInterceptor): def __init__(self): pass def invoke(self, invocation): tags = self.whoTaggedWho(invocation) def whoTaggedWho(self, invocation): character = invocation.instance return [character, character]
Now, here's my output (with the debug logger on)Code:pointcutAdvisor = RegexpMethodPointcutAdvisor(advice = [WrappingInterceptor()], patterns = [".*"]) self.characterAdvisor = ProxyFactoryObject(target = CommentatorCharacterObserver(), interceptors = pointcutAdvisor)
It never even looks into CommentatorCharacterObserver.whoTaggedWho, but does happily watch invoke. Am I formulating something wrong?Code:> : grep "CommentatorCharacterObserver" output 2008-11-10 18:27:08,262 - springpython.aop.RegexpMethodPointcut - DEBUG - Candidate is [CommentatorCharacterObserver.invoke]; pattern is [.*]; matched=True 2008-11-10 18:27:13,169 - springpython.aop.RegexpMethodPointcut - DEBUG - Candidate is [CommentatorCharacterObserver.invoke]; pattern is [.*]; matched=True 2008-11-10 18:27:13,171 - springpython.aop.RegexpMethodPointcut - DEBUG - Candidate is [CommentatorCharacterObserver.invoke]; pattern is [.*]; matched=True 2008-11-10 18:27:16,450 - springpython.aop.RegexpMethodPointcut - DEBUG - Candidate is [CommentatorCharacterObserver.invoke]; pattern is [.*]; matched=True 2008-11-10 18:27:16,452 - springpython.aop.RegexpMethodPointcut - DEBUG - Candidate is [CommentatorCharacterObserver.invoke]; pattern is [.*]; matched=True
I know that wrapping a wrapper is a bizarre thing to do. My intention is that the Commentator will be output agnostic, and then a database aspect will wrap round it and store things in a database. So here, whoTaggedWho would be wrapped by the database, so the event will be saved across sessions. Is there a more intelligent way to do this with AOP?
This is an experiment into whether the final project looks nicer than an OOP implementation, which it might well not!
I'm sorry to have been such a bother all the time![]()



Reply With Quote
