Commits

Anonymous committed 10aa9c7

Changed request.carts to a dict -- now the middleware actually works

Comments (0)

Files changed (1)

session_cart/middleware.py

         """
         Add the carts to the request object. 
         """
-        request.carts = object()
-        for name, Cart in get_carts().items():
-            setattr(request.carts, name, Cart(request, name))
-        
+        request.carts = dict(
+            (name, Cart(request, name))
+            for name, Cart in get_carts().items()
+        )
+
         if 'default' in get_carts():
-            request.cart = property(lambda self: self.carts.default)
+            request.cart = request.carts['default']
 
     def process_response(self, request, response):
         """
         # returned request this middleware's process_request was called.
         if hasattr(request, 'carts'):
             for name in get_carts():
-                getattr(request.carts, name).save()
+                request.carts[name].save()
         return response