arturtamborski / notion-py Goto Github PK
View Code? Open in Web Editor NEWThis project forked from jamalex/notion-py
(Fork of) Unofficial Python API client for Notion.so
Home Page: https://pypi.org/project/notion-py/
License: MIT License
This project forked from jamalex/notion-py
(Fork of) Unofficial Python API client for Notion.so
Home Page: https://pypi.org/project/notion-py/
License: MIT License
jamalex/notion-py/issues/ 45
Hello,
I am trying to create a new row to a notion database. The code used to work. I am still able to read the row contents but when I try to create a new row it gives me this error:
HTTPError: Unsaved transactions: SpaceShardRecordPointer have no space id
appreciate any help.
thanks
Something's wrong with setup.py?
Just started getting this error this evening.
Package has been working well for me, but suddenly getting a new error when I'm creating the client object:
client = NotionClient(token_v2=token)
I am now getting this error:
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\....\env\lib\site-packages\notion\client.py", line 157, in __init__ self._update_user_info() File "C:\....\env\lib\site-packages\notion\client.py", line 265, in _update_user_info data = self._store.store_record_map(data) File "C:....\env\lib\site-packages\notion\store.py", line 298, in store_record_map for record_id, record in records.items(): AttributeError: 'NoneType' object has no attribute 'items'
Checked to see if token has changed for some reason (it hasnt). Any ideas?
backport from upstream
https://github.com/jamalex/notion-py/pull/ 49
I found this repository due to the original not being updated - but I found that get collection view method works on that one but not on this version.
Code:
from notion.client import NotionClient
# Obtain the `token_v2` value by inspecting your browser cookies on a logged-in (non-guest) session on Notion.so
client = NotionClient(token_v2=<token>)
cv = client.get_collection_view(<url>)
print(cv)
It logs "None" where as the original version logs "id=''"
Am I missing something? Docs are the same as the original
Python 3.10.1 (main, Dec 6 2021, 22:18:13) [Clang 13.0.0 (clang-1300.0.29.3)]
IPython 8.0.1 -- An enhanced Interactive Python. Type '?' for help.
In [9]: page = client.get_collection(
...: "https://www.notion.so/stblr/0e8906b81ce24b8b9c9f10b6081aff32?v=5333
...: 131ec3f6453ea1690d2fd8c7e04d"
...: )
---------------------------------------------------------------------------
NotionValidationError Traceback (most recent call last)
Input In [9], in <module>
----> 1 page = client.get_collection(
2 "https://www.notion.so/stblr/0e8906b81ce24b8b9c9f10b6081aff32?v=5333131ec3f6453ea1690d2fd8c7e04d"
3 )
File /opt/homebrew/Cellar/ipython/8.0.1/libexec/lib/python3.10/site-packages/notion/client.py:376, in NotionClient.get_collection(self, collection_id, force_refresh)
353 def get_collection(
354 self, collection_id: str, force_refresh: bool = False
355 ) -> Optional[CollectionBlock]:
356 """
357 Retrieve an instance of Collection that maps to
358 the collection identified by the ID passed in.
(...)
374 Found collection or None.
375 """
--> 376 record_data = self.get_record_data(
377 "collection", collection_id, force_refresh=force_refresh
378 )
380 if record_data:
381 return CollectionBlock(self, collection_id)
File /opt/homebrew/Cellar/ipython/8.0.1/libexec/lib/python3.10/site-packages/notion/client.py:312, in NotionClient.get_record_data(self, table, url_or_id, force_refresh)
287 def get_record_data(
288 self, table: str, url_or_id: str, force_refresh: bool = False
289 ) -> dict:
290 """
291 Get record data.
292
(...)
310 Record data.
311 """
--> 312 return self._store.get(
313 table=table, url_or_id=url_or_id, force_refresh=force_refresh
314 )
File /opt/homebrew/Cellar/ipython/8.0.1/libexec/lib/python3.10/site-packages/notion/store.py:168, in RecordStore.get(self, table, url_or_id, force_refresh)
166 self.call_load_page_chunk(rid)
167 else:
--> 168 self.call_get_record_values(**{table: rid})
169 result = self._get(table, rid)
170 return result if result is not Missing else None
File /opt/homebrew/Cellar/ipython/8.0.1/libexec/lib/python3.10/site-packages/notion/store.py:262, in RecordStore.call_get_record_values(self, **kwargs)
260 logger.debug(f"Calling 'getRecordValues' endpoint for requests: {requests}")
261 data = {"requests": requests}
--> 262 data = self._client.post("getRecordValues", data).json()
263 results = data["results"]
265 for request, result in zip(requests, results):
File /opt/homebrew/Cellar/ipython/8.0.1/libexec/lib/python3.10/site-packages/notion/client.py:716, in NotionClient.post(self, endpoint, data, **kwargs)
713 msg = res_data.get("message") or "<message was not provided>"
715 if code == 400:
--> 716 raise NotionValidationError(msg, extra=res_data)
718 if code == 401:
719 raise NotionUnauthorizedError(msg, extra=res_data)
NotionValidationError: Invalid input.
readthedocs.org? :)
with Python 3.10.13
and the example of the README
from notion.client import NotionClient
token = "v02%3Auser_token_or_cookies%3..."
client = NotionClient(token_v2=token)
page = client.get_block(
"https://www.notion.so/..."
)
print(page.title)
I get the error
notion.client.NotionValidationError: Something went wrong. (400)
cv = client.get_collection_view(url)
row = cv.collection.add_row()
row.Author = "qwe"
row.Link = "http://www.somelink.com/123"
Given the code above.... how can I setup the icon for such row?
_______________________________ test_file_block ________________________________
notion = NotionTestContext(client=<notion.client.NotionClient object at 0x7f60163e1610>, root_page=...>)
def test_file_block(notion):
block = notion.root_page.children.add_new(FileBlock)
assert_block_is_okay(**locals(), type="file")
assert block.title == ""
assert block.source == ""
assert block.file_id is None
title = "requirements.txt"
block.upload_file(title)
block.title = title
block.refresh()
assert block.title == title
> assert "secure.notion-static.com" in block.source
E TypeError: argument of type 'NoneType' is not iterable
smoke_tests/block/test_upload.py:19: TypeError
https://github.com/arturtamborski/notion-py/runs/1085513350?check_suite_focus=true
It wasn't my intention to create alternative package to original API wrapper library. It became one though, which I'd like to track and fix in this issue.
What the heck is going on with this release? Been getting #76 also
I think the callbacks needs still to be fixed.
Can someone say, why or what is broken with monitoring/callbacks?
Maybe I can help then.
It's used in only one place and it's just an unnecessary baggage.
as in jamalex/notion-py/issues/ 16
How can I add a TextBlock with a mention to @today
or @now
?
page.children.add_new(TextBlock, title="@now hello world")
jamalex/notion-py/issues/ 45
In the table block, when creating columns (properties), the column id can contain a dot symbol. For example =f).
(i have this one, when i found bug).
In this case, when calling the get_property()
method, None
will be returned.
This happens because in the function notion.utils.get_by_path()
the path
is split by a dot:
path = path.split(".")
This is probably because notion.so changed something on their side, the endpoint searchBlocks
seems to be no longer valid.
I'm expecting some dust in here, code wasn't touched for a while.
This ticket is for having a quick, random and open discussion on anything that relates to notion
, notion-py
and notion.so
.
You can treat it as an IRC log / project "blog" in form of a Github issue :)
I will pick highly rated or interesting ideas from conversation and copy them over here or create a separate issue.
It's a place to share your feedback and opinions openly (but please keep your posts related to notion-py/notion.so).
It's also an online substitute of the TODO.md file.
Please note that it's just an experiment. I don't know if this will work out, especially since there aren't that many people around here anyway, but it's an idea that I wanted to try out and see how it ends up.
jamalex's codebase does return the rows correctly here but obviously I'm trying to pivot to a supported repo.
Not sure whats going on here; its possible I have screwed up pulling the collection view? I cannot find a Collection
object associated with my view.
>>> cv.get_rows()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'TableView' object has no attribute 'get_rows'
>>> cv.collection.get_rows()
[
<CollectionViewBlock (id='07...d1', caption='', type='page', collection=None, title='')>,
<CollectionViewBlock (id='23...a5', caption='', type='page', collection=None, title='')>
]
Hi @arturtamborski
Could you please advice me. Is any way to create page link block with py-noton?
Hardcode some page id and a token for it (in secrets) from some fake account created for this project
I moved from a different fork of notion-py and some code broke
I looked around a bit, and found that the problem is deeper - in /notion/collection.py, convert_notion_to_python, 465:
for i, part in enumerate(val):
Therefore, this val == None
The function got this Val from from get_property, line 404
val = self.get(["properties", prop["id"]])
The .get is from the Record class, but i don't know what goes wrong there
Edit: translated into english
I thought about using poetry as well but we might not need it for now.
Github Actions are well suited for it
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.