-
-
Notifications
You must be signed in to change notification settings - Fork 368
master: Updated Diff to Catch TypeError #166
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,10 @@ def current(self, fields=None): | |
def has_changed(self, field): | ||
"""Returns ``True`` if field has changed from currently saved value""" | ||
if field in self.fields: | ||
return self.previous(field) != self.get_field_value(field) | ||
try: | ||
return self.previous(field) != self.get_field_value(field) | ||
except TypeError: | ||
return True | ||
else: | ||
raise FieldError('field "%s" not tracked' % field) | ||
|
||
|
@@ -172,8 +175,16 @@ def changed(self): | |
return {} | ||
saved = self.saved_data.items() | ||
current = self.current() | ||
return dict((k, v) for k, v in saved if v != current[k]) | ||
|
||
dict = {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's not use |
||
for k, v in saved: | ||
try: | ||
if v != current[k]: | ||
dict.update({k:v}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this would be simpler as |
||
except TypeError: | ||
dict.update({k:v}) | ||
return dict | ||
#return dict((k, v) for k, v in saved if v != current[k]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to keep this around. |
||
|
||
|
||
class ModelTracker(FieldTracker): | ||
tracker_class = ModelInstanceTracker | ||
|
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.
In our current issue situation, it will mask the
TypeError
, which will be even harder to detect. I think we should properly handle timezone related issues.