Commits

Anonymous committed 45ce403

Moved model and session key to class attributes

Comments (0)

Files changed (2)

 
 class Cart( list ):
     '''Handles a list of items stored in the session'''
+    model = None
+    key = 'cart'
     def __init__( self, request, items =None, model=None ):
         super( Cart, self ).__init__()
         self.request = request
-        self.model = model
         if items is not None:
             for item in items:
                 self.add_item( item.item, item.quantity )
         else:
             # Cart is stored as a list of ( item_id, quantity )
-            for prod, quantity in request.session.get('cart', [] ):
+            for prod, quantity in request.session.get(self.key, [] ):
                 try:
                     self.add_item( prod, quantity )
                 except self.model.DoesNotExist:
 
     def save( self ):
         '''Save this cart to the session'''
-        self.request.session['cart'] = tuple(
+        self.request.session[self.key] = tuple(
             ( i.item.id, i.quantity, )
             for i in self
         )
     def __repr__( self ):
         return ','.join([ str(x) for x in self])
 
+
 
 setup( name='django-session-cart',
 	version='1.0',
-	py_modules=['session_cart']
+	description='A session-stored cart for Django',
+	author='Curtis Maloney',
+	author_email='curtis@tinbrain.net',
+	url='http://bitbucket.org/funkybob/django-session-cart/',
+	keywords=[ 'django', 'cms', 'e-commerce', ],
+	py_modules=['session_cart'],
+	zip_safe=False,
 )