Commits

James Bennett  committed f64ded8

Signals should send the request object as well.

  • Participants
  • Parent commits 6bcbce9

Comments (0)

Files changed (4)

File docs/backend-api.rst

 ``user``
     The ``User`` instance representing the new account.
 
+``request``
+    The ``HttpRequest`` in which the user registered.
+
 Finally, this method should return the ``User`` instance.
 
 
 ``user``
     The ``User`` instance representing the new account.
 
+``request``
+    The ``HttpRequest in which the user activated.
+
 This method should then return the ``User`` instance.
 
 For workflows which do not require a separate activation step, this

File registration/backends/default/__init__.py

             site = RequestSite(request)
         new_user = RegistrationProfile.objects.create_inactive_user(username, email,
                                                                     password, site)
-        signals.user_registered.send(sender=self.__class__, user=new_user)
+        signals.user_registered.send(sender=self.__class__,
+                                     user=new_user,
+                                     request=request)
         return new_user
 
     def activate(self, request, activation_key):
         """
         activated = RegistrationProfile.objects.activate_user(activation_key)
         if activated:
-            signals.user_activated.send(sender=self.__class__, user=activated)
+            signals.user_activated.send(sender=self.__class__,
+                                        user=activated,
+                                        request=request)
         return activated
 
     def registration_allowed(self, request):

File registration/signals.py

 
 
 # A new user has registered.
-user_registered = Signal(providing_args=["user"])
+user_registered = Signal(providing_args=["user", "request"])
 
 # A user has activated his or her account.
-user_activated = Signal(providing_args=["user"])
+user_activated = Signal(providing_args=["user", "request"])

File registration/tests/backends.py

         def receiver(sender, **kwargs):
             self.failUnless('user' in kwargs)
             self.assertEqual(kwargs['user'].username, 'bob')
+            self.failUnless('request' in kwargs)
+            self.failUnless(isinstance(kwargs['request'], WSGIRequest))
             received_signals.append(kwargs.get('signal'))
 
         received_signals = []
         def receiver(sender, **kwargs):
             self.failUnless('user' in kwargs)
             self.assertEqual(kwargs['user'].username, 'bob')
+            self.failUnless('request' in kwargs)
+            self.failUnless(isinstance(kwargs['request'], WSGIRequest))
             received_signals.append(kwargs.get('signal'))
 
         received_signals = []