From 0ebe67772c5c90d947549d25e215ca0b0152b7b3 Mon Sep 17 00:00:00 2001 From: Joel Knight Date: Tue, 22 Mar 2022 22:03:42 -0600 Subject: [PATCH] fix(collections): up-to-date lookup for collection_id It appears something change in the Notion API which causes errors when working with recently created databases. This results in being unable to find the `collection_id` of a `CollectionViewBlock` which has downstream affects such as exceptions when trying to access the `title` property of the database and being unable to add rows to the collection. This commit changes how the `collection_id` is retrieved within the `CollectionViewBlock` class such that the lookup succeeds for newish and oldish databases. Fixes https://github.com/jamalex/notion-py/issues/367 --- notion/block.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/notion/block.py b/notion/block.py index f19784f9..d5192744 100644 --- a/notion/block.py +++ b/notion/block.py @@ -714,7 +714,7 @@ class CollectionViewBlock(MediaBlock): @property def collection(self): - collection_id = self.get("collection_id") + collection_id = self.get("format.collection_pointer.id") if not collection_id: return None if not hasattr(self, "_collection"): @@ -725,7 +725,7 @@ def collection(self): def collection(self, val): if hasattr(self, "_collection"): del self._collection - self.set("collection_id", val.id) + self.set("format.collection_pointer.id", val.id) @property def views(self):