Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

store wishlist in database #59

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

dfalk
Copy link
Contributor

@dfalk dfalk commented Sep 2, 2012

Wishlist with email notifications on stock updating.

@travisbot
Copy link

This pull request fails (merged a5b7b4f into 1586508).

@dfalk dfalk closed this Sep 2, 2012
@dfalk dfalk reopened this Sep 2, 2012
@travisbot
Copy link

This pull request fails (merged a5b7b4f into 1586508).

@travisbot
Copy link

This pull request passes (merged 5e026f3 into 1586508).

@dfalk
Copy link
Contributor Author

dfalk commented Sep 10, 2012

any thoughts?

@stephenmcd
Copy link
Owner

Yeah it's a great idea - once I have some time I'll go through it, hopefully soon.

Thanks Dmitry

@rterbush
Copy link

This is a must have feature. Anything we can do to help get this into a release?

@stephenmcd
Copy link
Owner

Sorry for letting this one fall by the wayside, I'd completely forgotten about it. I've gone over it now and there are a few issues to address.

The primary concern is that there are actually two distinct features implemented here. First is allowing registered users to create persistent wishlists tied to their account, not their session. I'm all for this feature and I think it'd be a great addition. The second thing it implements is bulk emailing. If a product was in 100s of users wishlists and they were to be notified, with the way this is implemented, the server would be tied up handling the admin's request to send all these out. I use an arbitrary value of "100s" here, but the number is irrelevant - the point is that it introduces a scaling issue which is unsafe. Interestingly as the number of potential emails being sent out grows, you can conclude that popularity of the site itself also grows, and so the need to not have requests tied up by something like this becomes more of a concern. The good news is that with the DB backed wishlists, a project developer should be able to hook into Django's signals to implement this feature themselves, using whatever mailing approach they'd like to. So ultimately the email feature needs to be removed from this code.

A couple of other minor points.

It'd be good if there was a BaseWishlist class that implements the methods for adding and retrieving items from the user's session. The model-based Wishlist could then subclass it, and override those methods appropriately. We could then have one point in the code that determines which class to use (based on whether the user is authenticated), and then all of the form/view code would not need all the branching it has in it within the approach implemented in this pull request.

Finally, unfortunately this pull request won't merge cleanly at this point in time. Again this is my fault for letting things lag for so long, which I apologise for, but given the above feedback I've made, isn't too big of an issue since it needs more work anyway.

@uranusjr
Copy link
Contributor

Hi,

I've taken some time into the code and made some changes. I couldn't reach @dfalk so I figure I probably should post here first. Changes include adding a setting entry to disable email notification, and putting most of the wishlist adding/deleting/fetching logic in WishlistManager (Wishlist.objects)

I considered using inheritance and patching __new__ to abstract the wishlist updating mechanism, but was unsatisfied with both. Putting HTTP related codes into a model that is inherited by a model just doesn't feel right for me, and overriding __new__ just seems hacky. In the end I opt for the simple route:

  1. Add a separate dummy class utils.CookieBackedWishlist that understands HttpRequest objects, and update request.wishlist when necessary.
  2. Use a helper function utils.get_wishlist instead of calling Wishlist() to instantiate a new wishlist entry.
  3. Always call set_cookie to update the cookie-backed wishlist when a view updates the wishlist — this doesn't really hurt anyway.

I'd like to hear about it if someone has a cleaner way to do this. You can view my branch is here, which rebased @dfalk's work and applied the changes mentioned .

@stephenmcd
Copy link
Owner

Hey @uranusjr - thanks a lot for this. Do you want to set up an initial pull request with your changes?

@uranusjr
Copy link
Contributor

Sure, will do.

@stepmr
Copy link

stepmr commented Aug 14, 2013

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants