-
Notifications
You must be signed in to change notification settings - Fork 285
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
Python 3 and django 1.5 compatability #71
Conversation
pass | ||
finally: | ||
pass | ||
return self.current_subscription.is_valid() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you move this from outside of the exception block where if the CurrentSubscription
didn't exist it would return False
instead of blow up with an Exception?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I confused myself when I was looking at it. And it passed the tests in the new configuration. I'll return it to it's previous state and run the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could use a test for that case. Coverage isn't there yet. Been adding tests as I add or change things or regressions are reported.
Sent from my iPhone
On Jul 26, 2013, at 1:39 PM, Daniel Greenfeld [email protected] wrote:
In payments/models.py:
except CurrentSubscription.DoesNotExist: return False
except Exception as e:
raise
else:
pass
finally:
pass
I think I confused myself when I was looking at it. And it passed the tests in the new configuration. I'll return it to it's previous state and run the tests.return self.current_subscription.is_valid()
—
Reply to this email directly or view it on GitHub.
@pydanny thanks for the PR, still reviewing some bits, but could you go ahead an address the comments I already left as well as investigate the bulid failure? Would be great if you could add Python 3 directives in the .travis.yml file while you are at it. Thanks! |
In addition to the inline changes, I also added Python 3.3 to the .travis.yml file. I could also do 3.2 but in my experiences getting production level Django to work well with 3.2 can be finicky. We ignore that iteration of Python. Up to you... |
Oops - Travis is running 3.3 against Django 1.4, which will break. Let me see what I can do with the config file |
…s, and removed unnecessary QueryDict import
|
||
|
||
class CustomerManager(models.Manager): | ||
|
||
def started_during(self, year, month): | ||
# Need to implement datetime range because 'start' field is DateTimeField | ||
start_date = timezone.datetime(year, month, 1, tzinfo=timezone.utc) | ||
end_date = timezone.datetime(year, month + 1, 1, tzinfo=timezone.utc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pydanny what happens in December? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add some tests for this manager method (and the other datetime methods you are changing)?
Should be good now. |
it's failing on the pylint and there is nothing I can do to get around it. Problems:
I'm stuck and can't get past it. |
@paltman Any movement on this? I'm getting stuck on the Eldarion linter which doesn't seem to like Django 1.5 custom user model fix and so throws an error. |
from django.conf import settings | ||
from django.core.exceptions import ImproperlyConfigured | ||
from django.utils import importlib | ||
|
||
try: | ||
from django.contrib.auth import get_user_model |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pydanny you can add a disable message:
from django.contrib.auth import get_user_model # pylint: disable-msg=E0611
I'm on it! |
@pydanny the error in the 3.3 travis run looks like an issue with the version of distribute under python 3.3 when running the setup.py. I don't have a Python 3 environment locally to try an reproduce but you might try installing locally in a new virtualenv the setup.py and debug from there. |
Okay, just set up new environment and I'm getting the same problem. But not in my old one. How weird? Okay... digging in. |
@pydanny from the stack trace it looks like something in building the long description, so I wonder if it's something in this function that Python 3 doesn't like: https://github.com/eldarion/django-stripe-payments/blob/master/setup.py#L10 |
The three other lint errors seem to be indented white space issues in |
All tests pass locally on all tested versions of Python. On travis, everything but Python 3 passes, and Python 3 fails because Pylint does't work with Python 3. See https://travis-ci.org/eldarion/django-stripe-payments |
Hm... I wonder if this is helpful http:https://stackoverflow.com/questions/10772824/no-luck-pip-installing-pylint-for-python-3 I don't have much time to debug this right now (this week is crazy busy for me). I realize this could likely just be a Travis issue but really don't want to merge under we sort out Travis / pylint issues. I dig into this as soon as I have time to figure out why pylint is breaking in this configuration as docs seem to indicate pylint is supported on Python 3. Might not be until next week though. |
return self.exclude( | ||
current_subscription__status="trialing" | ||
).filter( | ||
current_subscription__start__year=year, | ||
current_subscription__start__month=month | ||
current_subscription__start__range=get_range(year, month), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain to me in more detail why this change is required? I fired up a 1.5 project with Python 2 and 3 to see if I could see any reason for this change, but I am not finding any. The Django documentation doesn't even mention the need for this kind of change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because django-stripe-payments mixes Date calculations with DateTime fields. It uses DateTimeField but treats them like DateFields. I was actually surprised this wasn't opened as an issue earlier.
There is actually a lot of stuff about this available, including in the Django docs, but for now there is http:https://stackoverflow.com/a/10048320/93270
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see what I was doing as mixing "Date calculation with DateTime fields". I am merely filtering a DateTimeField by it's year and month component. I don't see what the the problem is with that. Granted I haven't used Python 3 at all, but also not sure why Python 3 would/should change how a queryset of a DateTimeField works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue reported in the StackOverflow link is not really relevant. I am not saying there isn't an issue here. I really want be shown what it is though. The problem on SO is that poster is trying to compare datetimes in the databases to a very specific datetime or a date object. It is easy to see that won't work because equality checks will require an exact match. When Django is given a date object to do a datetime comparison it will just fill in the time with midnight.
We are not doing that in the code you've changed. We are using __year
and __month
lookups which result in SQL like:
WHERE (EXTRACT(\'month\' FROM "product_subscription"."start") = 6 AND "product_subscription"."start" BETWEEN 2013-01-01 00:00:00 and 2013-12-31 23:59:59.999999)
Which doesn't suffer from the problem being reported on SO.
I assume you made this change because you saw a real issue. If you can help me reproduce this issue I'd be glad to accept a fix for it.
Furthermore, I don't see how this is relevant to goal of the PR which is add Python 3 and Django 1.5 support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought I had a failure in the tests on Python 3, hence the change. I'll undo the changes and see what happens.
Since Eldarion insists on using a linter in Travis-CI, I'll let Eldarion address the issue. Hate to go this way, but if my deadline gets much closer, I'll need to port this library and release it as a stable dependency on PyPI. |
That's fine. You have to do what you have to do when you have deadlines. I don't really feel comfortable removing the linter just to support this case. |
I got the deadline pushed back a couple weeks for so I should have time to see this to the end. |
Okay, back to it:
|
Client has agreed to move to Python 2.7 for now as there are too many packages to update to get project working on Python 3. Which means I'm closing this pull request for now. I might try and work it again in the future. |
Fix sync account next
This pull request does the following:
What this pull request doesn't do: