Skip to content

Commit

Permalink
fix(collections): up-to-date lookup for collection_id
Browse files Browse the repository at this point in the history
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 jamalex#367
  • Loading branch information
knightjoel authored Mar 23, 2022
1 parent c9223c0 commit 0ebe677
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions notion/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand All @@ -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):
Expand Down

1 comment on commit 0ebe677

@jessecheu
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix solves the 'NoneType' issue with collection.add_row().

Please sign in to comment.