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

Max recursion depth exceeded in lfs.discount.utils #175

Open
ravigadila opened this issue Feb 28, 2015 · 3 comments
Open

Max recursion depth exceeded in lfs.discount.utils #175

ravigadila opened this issue Feb 28, 2015 · 3 comments

Comments

@ravigadila
Copy link

https://github.com/diefenbach/django-lfs/blob/master/lfs/discounts/utils.py#L10

case 1:
When i pass product to -> if discount.is_valid(request, product) max recursion depth exceeded,
and i tried sys.setrecursionlimit(2000) but no use.
case 2:
In testing server we added 100 orders(with discount) manually, in that 100 orders randomly( up to 30 ) discount doesn't added.

@pigletto
Copy link
Collaborator

Case 1:
Can you provide the code and details of the product that you're using?

Case 2:
Can you provide more details? What kind of discount do you have? Are there any products assigned to it? Are there any criteria?

Also, is this possible to reproduce issue eg. when you create new order that is same as one that has no discount applied? If so then can you provide details of products in this order?

@ravigadila
Copy link
Author

Case 1:

https://github.com/diefenbach/django-lfs/blob/master/lfs/criteria/models.py#L375
above code changed to as per my requirements to calculate shipping cost.
from lfs.discounts.utils import get_valid_discounts
disc = 0.0
if self.product:
price = self.product.get_price(self.request)
discounts = get_valid_discounts(self.request, item.product)
disc = discounts['discount_gross']

    elif self.cart:
        price = self.cart.get_price_gross(self.request)
        for item in self.cart.get_items():
            discounts = get_valid_discounts(self.request, item.product) * item.amount
            disc = disc + discounts['discount_gross']
    else:
        price = 0
    price = price - disc

Case2:
used default django-lfs apps (lfs.checkout) to calculate discounts.
reproduced same discounts(failed discounts) this time discount successfully added without any problem.

@pigletto
Copy link
Collaborator

pigletto commented Mar 5, 2015

In this case it is your code that causes problem as it doesn't seem to happen with original LFS code. Have a look at your traceback to see what causes the infinite recursion. Possibly call to 'get_valid_discounts'

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

No branches or pull requests

2 participants