Looking at the django-cart open source code:

cart = request.session.get('cart', None) or Cart()

Does the new cart object that recently got created be put back into
request.session['cart'].

I was thinking of improving the code located in
http://code.google.com/p/django-cart/source/browse/trunk/django-cart/shop/views.py
by adding a get_cart()

def get_cart(request):
    cart = request.session['cart']
    if cart == None
       cart = Cart()
       cart.save()
       request.session['cart'] = cart
    return cart

Is there a cleaner way of doing this.

Thanks in advance.

On Mar 13, 3:57 pm, sotirac <soti...@gmail.com> wrote:
> What is happening here:
>
> fav_color = request.session.get('fav_color', 'red')
>
> Is it trying to retrieve 'fav_color' from the session.  If it doesn't
> exist, does it put it in the session and assign the value 'red' for
> it.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to