home
·
contact
·
privacy
projects
/
plomtask
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix bug of same dict being used for different Classes' caches.
[plomtask]
/
plomtask
/
days.py
diff --git
a/plomtask/days.py
b/plomtask/days.py
index d838039a715677ffb3c9022f82715859d80fd652..258d38dbbf1d7f920f36ca06c9f8292506d16807 100644
(file)
--- a/
plomtask/days.py
+++ b/
plomtask/days.py
@@
-24,11
+24,10
@@
def todays_date() -> str:
return datetime.now().strftime(DATE_FORMAT)
return datetime.now().strftime(DATE_FORMAT)
-class Day(BaseModel):
+class Day(BaseModel
[str]
):
"""Individual days defined by their dates."""
table_name = 'days'
to_save = ['comment']
"""Individual days defined by their dates."""
table_name = 'days'
to_save = ['comment']
- id_type = str
def __init__(self, date: str, comment: str = '') -> None:
self.id_: str = valid_date(date)
def __init__(self, date: str, comment: str = '') -> None:
self.id_: str = valid_date(date)
@@
-72,13
+71,11
@@
class Day(BaseModel):
"""Retrieve Day by date if in DB (prefer cache), else return None."""
day, _ = super()._by_id(db_conn, date)
if day:
"""Retrieve Day by date if in DB (prefer cache), else return None."""
day, _ = super()._by_id(db_conn, date)
if day:
- assert isinstance(day, Day)
return day
if not create:
raise NotFoundException(f'Day not found for date: {date}')
day = cls(date)
return day
if not create:
raise NotFoundException(f'Day not found for date: {date}')
day = cls(date)
- db_conn.cached_days[date] = day
- assert isinstance(day, Day)
+ day.cache()
return day
@property
return day
@property