|
22 | 22 | from .elements import dav |
23 | 23 | from .elements.base import BaseElement |
24 | 24 | from .lib import error |
| 25 | +from .lib.dav_core import DAVObjectCore |
25 | 26 | from .lib.python_utilities import to_wire |
26 | 27 | from .lib.url import URL |
27 | 28 |
|
|
36 | 37 | log = logging.getLogger("caldav") |
37 | 38 |
|
38 | 39 |
|
39 | | -class AsyncDAVObject: |
| 40 | +class AsyncDAVObject(DAVObjectCore): |
40 | 41 | """ |
41 | 42 | Async base class for all DAV objects. |
42 | 43 |
|
@@ -71,33 +72,15 @@ def __init__( |
71 | 72 | props: a dict with known properties for this object |
72 | 73 | id: The resource id (UID for an Event) |
73 | 74 | """ |
74 | | - if client is None and parent is not None: |
75 | | - client = parent.client |
76 | | - self.client = client |
77 | | - self.parent = parent |
78 | | - self.name = name |
79 | | - self.id = id |
80 | | - self.props = props or {} |
81 | | - self.extra_init_options = extra |
82 | | - |
83 | | - # URL handling |
84 | | - path = None |
85 | | - if url is not None: |
86 | | - self.url = URL.objectify(url) |
87 | | - elif parent is not None: |
88 | | - if name is not None: |
89 | | - path = name |
90 | | - elif id is not None: |
91 | | - path = id |
92 | | - if not path.endswith(".ics"): |
93 | | - path += ".ics" |
94 | | - if path: |
95 | | - self.url = parent.url.join(path) |
96 | | - # else: Don't set URL to parent.url - let subclass or save() generate it properly |
| 75 | + # Initialize using parent class which handles all the common logic |
| 76 | + # This fixes the URL initialization to match sync behavior |
| 77 | + super().__init__(client, url, parent, name, id, props, **extra) |
97 | 78 |
|
| 79 | + @property |
98 | 80 | def canonical_url(self) -> str: |
99 | 81 | """Return the canonical URL for this object""" |
100 | | - return str(self.url.canonical() if hasattr(self.url, "canonical") else self.url) |
| 82 | + # Use parent class implementation |
| 83 | + return self.get_canonical_url() |
101 | 84 |
|
102 | 85 | async def _query_properties( |
103 | 86 | self, props: Optional[List[BaseElement]] = None, depth: int = 0 |
@@ -223,12 +206,4 @@ async def delete(self) -> None: |
223 | 206 | """Delete this object from the server""" |
224 | 207 | await self.client.delete(str(self.url)) |
225 | 208 |
|
226 | | - def get_display_name(self) -> Optional[str]: |
227 | | - """Get the display name for this object (synchronous)""" |
228 | | - return self.name |
229 | | - |
230 | | - def __str__(self) -> str: |
231 | | - return f"{self.__class__.__name__}({self.url})" |
232 | | - |
233 | | - def __repr__(self) -> str: |
234 | | - return f"{self.__class__.__name__}(url={self.url!r}, client={self.client!r})" |
| 209 | + # get_display_name, __str__, and __repr__ are inherited from DAVObjectCore |
0 commit comments