Modify

Opened 2 years ago

Closed 2 years ago

#14149 closed defect (fixed)

AttributeError: 'datetime.date' object has no attribute 'date'

Reported by: anonymous Owned by: lucid
Priority: normal Component: WeekPlanPlugin
Severity: normal Keywords:
Cc: Trac Release:

Description

2022-08-09 08:45:55,345 Trac[main] ERROR: [212.126.160.88] Internal Server Error: <RequestWithSession "GET '/weekplan?start=2022-08-08&end=2022-10-03'">
Traceback (most recent call last):
  File "build\bdist.win-amd64\egg\trac\web\main.py", line 611, in dispatch_request
    dispatcher.dispatch(req)
  File "build\bdist.win-amd64\egg\trac\web\main.py", line 250, in dispatch
    resp = chosen_handler.process_request(req)
  File "build\bdist.win-amd64\egg\weekplan\core.py", line 196, in process_request
    self._send_events(req, events)
  File "build\bdist.win-amd64\egg\weekplan\core.py", line 213, in _send_events
    self._send_json(req, [e.serialized(self.env, context) for e in events])
  File "build\bdist.win-amd64\egg\weekplan\model.py", line 33, in serialized
    'start': self.start.date().isoformat(),
AttributeError: 'datetime.date' object has no attribute 'date'

Attachments (0)

Change History (3)

comment:1 Changed 2 years ago by anonymous

#14110 ical seems to give sometimes datetime.datetime (OK) but sometimes datetime.date (unexpected by WeekPlanPlugin).

comment:2 Changed 2 years ago by anonymous

Replacing this line with this seems to help:

-            return WeekPlanEvent(str(entry_id), plan, title, start.dt, end.dt)
+            start = start.dt
+            end = end.dt
+            if isinstance(start, datetime.date):
+                start = datetime.datetime.combine(start, datetime.time(12, 0))
+            if isinstance(end, datetime.date):
+                end = datetime.datetime.combine(end, datetime.time(12, 0))
+            return WeekPlanEvent(str(entry_id), plan, title, start, end)

comment:3 Changed 2 years ago by lucid

Resolution: fixed
Status: newclosed

In 18497:

WeekPlanPlugin: ical recurring events support
(fix #14122)

Fix AttributeError: 'datetime.date' object has no attribute 'date' (fix #14149)

Fix extras_require (see #14110)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain lucid.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.