diff options
author | Daniel Schadt <kingdread@gmx.de> | 2022-07-17 20:54:28 +0200 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2022-07-17 20:54:28 +0200 |
commit | 7e86285887866ed10bc9868a0f9aa3b5e5094aba (patch) | |
tree | 226c542771937b92c28dd76b6b4e74435cd42a72 | |
parent | b9bbeafafb1f0750e4adaf12462b86094a5cad25 (diff) | |
download | fietsboek-7e86285887866ed10bc9868a0f9aa3b5e5094aba.tar.gz fietsboek-7e86285887866ed10bc9868a0f9aa3b5e5094aba.tar.bz2 fietsboek-7e86285887866ed10bc9868a0f9aa3b5e5094aba.zip |
track: don't fail when id is not set
This is just debug logging information, but accessing self.id for an
object that is not in the database raises an error, because self.id is
None and %d cannot format None. In this case, we simply use -1 as id
instead.
-rw-r--r-- | fietsboek/models/track.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/fietsboek/models/track.py b/fietsboek/models/track.py index 58e9745..1b1c38a 100644 --- a/fietsboek/models/track.py +++ b/fietsboek/models/track.py @@ -275,7 +275,7 @@ class Track(Base): def date(self, value): if value.tzinfo is None: LOGGER.debug('Non-aware datetime passed (track_id=%d, value=%s), assuming offset=0', - self.id, value) + self.id or -1, value) self.date_tz = 0 else: self.date_tz = value.tzinfo.utcoffset(value).total_seconds() // 60 @@ -576,7 +576,7 @@ class TrackCache(Base): def start_time(self, value): if value.tzinfo is None: LOGGER.debug('Non-aware datetime passed (cache_id=%d, value=%s), assuming offset=0', - self.id, value) + self.id or -1, value) self.start_time_tz = 0 else: self.start_time_tz = value.tzinfo.utcoffset(value).total_seconds() // 60 @@ -599,7 +599,7 @@ class TrackCache(Base): def end_time(self, value): if value.tzinfo is None: LOGGER.debug('Non-aware datetime passed (cache_id=%d, value=%s), assuming offset=0', - self.id, value) + self.id or -1, value) self.end_time_tz = 0 else: self.end_time_tz = value.tzinfo.utcoffset(value).total_seconds() // 60 |