Uploaded image for project: 'SX Spring Python'
  1. SX Spring Python
  2. SESPRINGPYTHONPY-134

AOPProxy throws an error unless target.__class__.__name__ == "instance"

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: 1.0.0.GA
    • Fix Version/s: 1.2.0.RC1, 1.1.1
    • Component/s: AOP
    • Labels:
      None
    • Environment:
      python 2.6 linux 32 bit virtual environment

      Description

      see this code...

      #
      from springpython.config import PythonConfig, Object as SpringObject
      from springpython.context import scope
      from springpython.context import ApplicationContext
      from springpython.aop import MethodInterceptor, ProxyFactory

      class WrappingInterceptor(MethodInterceptor):

      def invoke(self, invocation):
      return "<wrapped>" + invocation.proceed() + "</wrapped>"

      class BogusLister(object):

      def _getitem_(self, key):
      return key

      def fuckingDuh(self):
      return "Fucking Duh"

      class BogusFinder(object):

      def _init_(self, filename):
      self._filename = filename

      class BogusApplicationContext(PythonConfig):

      def _init_(self):
      super(BogusApplicationContext, self)._init_()

      @SpringObject(scope.PROTOTYPE)
      def BogusLister(self):
      factory = self.aopFactory()
      lister = BogusLister()
      lister.finder = self.BogusFinder()
      lister.description = self.SingletonString()
      self.logger.debug("Description=%s" % lister.description)
      factory.target=lister
      factory.target._class.name_ = "instance" #wtf?
      return factory.getProxy()

      @SpringObject(scope.SINGLETON)
      def BogusFinder(self):
      return BogusFinder(filename = "movies.txt")

      @SpringObject(scope.SINGLETON)
      def SingletonString(self):
      return "this is the only string"

      @SpringObject(scope.PROTOTYPE)
      def aopFactory(self):
      factory = ProxyFactory()
      factory.interceptors.append(WrappingInterceptor())
      return factory

      context = ApplicationContext(BogusApplicationContext())

      #---------offending source springpython/aop/_init_/py----------#
      169 def _init_(self, target, interceptors):
      170 if type(target)._name_ != "instance":
      171 -> raise Exception("Target attribute must be an instance.")

      i can't imagine why this conditional is necessary, but I'm not an aop expert either.

        Attachments

          Activity

            People

            • Assignee:
              gregturn Greg Turnquist
              Reporter:
              twillis Tom Willis
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: