title: How to use a decorator in class level correctly?
body: <p>I have a message bus, and a class subscribes many methods to the message bus, for example:</p>
  
  <pre><code>class BookingService(object):
      def start(self):
          self.msg_bus.login(self.user, self.password)
          self.msg_bus.subscribe('/broadcast/aliveResponse', self.handleAliveResponse)
          self.msg_bus.subscribe('/broadcast/musicInfoUpdated', self.handleMusicInfo)
          self.msg_bus.subscribe('/broadcast/radioOnline', self.handleRadioOnline)
          self.msg_bus.subscribe('/broadcast/radioOffline', self.handleRadioOffline)
          self.msg_bus.subscribe('/broadcast/online', self.handleBroadcastOnline)
          self.msg_bus.subscribe('/proxy/aliveResponse', self.handleEvent)
          self.msg_bus.subscribe('/proxy/online', self.handleProxyOnline)
          self.msg_bus.subscribe('/proxy/radioReady', self.handleEvent)
          self.msg_bus.subscribe('/proxy/radioUpdate', self.handleEvent)
          self.msg_bus.subscribe('/proxy/radioClosed', self.handleEvent)
          self.msg_bus.subscribe('/message_bus/detached', self.handleDetached)
          self.msg_bus.run()
  </code></pre>
  
  <p>It works, but it is difficult to understand what is the message path for each method, what I want is to use a decorator to subscribe to the message bus with method, it would looks like this</p>
  
  <pre><code>class BookingService(object):
  
      @subscribe('/broadcast/aliveResponse')
      @subscribe('/broadcast/onLine')
      def handleEvent(self, dest, data):
          print dest, data
  
      @subscribe('/proxy/aliveResponse')
      def handleAnotherEvent(self, dest, data):
          print dest, data
  </code></pre>
  
  <p>But here are some difficulty to solve, first of all, the msg_bus attribute belongs to instance, namely, to self.  I can't get the self.msg_bus in class level.  To solve this problem, I can write it like this:</p>
  
  <pre><code>class BookingService(object):
  
      subscribations = []
      def subscribe(dest):
          """Decorator for subscribing function to destination
  
          """
          def callee(func):
              subscribations.append((dest, func))
              return func
          return callee
  
      def subscribe_all(self):
          for dest, func in self.subscribations:
              self.msg_bus.subscribe(dest, func)
  
      @subscribe('/broadcast/aliveResponse')
      def handleEvent(self, dest, data):
          print dest, data
  
      def start(self):
          self.subscribe_all()
  </code></pre>
  
  <p>I try to collect subscriptions into BookingService.subscribations and add them to msg_bus later in subscribe_all, but here comes the problem.  I got an error</p>
  
  <pre><code>subscribations.append((dest, func))
  NameError: global name 'subscribations' is not defined
  </code></pre>
  
  <p>It seems that the subscribations is not in the scope of subscribe function, how to solve this problem? </p>