1. Ralph Bean
  2. tw2.captcha

Commits

Ralph Bean  committed 9a0628e

Delay controller registration until display preparation.

  • Participants
  • Parent commits 6002ba8
  • Branches default

Comments (0)

Files changed (1)

File tw2/captcha/widgets.py

View file
         random.seed()
         cls.aes = AES.new(cls._key, AES.MODE_ECB)
 
-        # Register our widget's built-in controller with the middleware
-        # This allows subsequent requests (for the image and the audio) to make
-        # their way to this widget's `request` method.
-        mw = twc.core.request_local()['middleware']
-        mw.controllers.register(cls, cls.controller_prefix)
-
     @classmethod
     def load_jpeg_generator(cls):
         name = cls.jpeg_generator
 
         self.payload = self.create_payload()
 
+        # Register our widget's built-in controller with the middleware
+        # This allows subsequent requests (for the image and the audio) to make
+        # their way to this widget's `request` method.
+        mw = twc.core.request_local()['middleware']
+        mw.controllers.register(type(self), self.controller_prefix)
+
     def create_payload(self):
         "Create a payload that uniquely identifies the captcha."
         c = model.Captcha()