Giter Club home page Giter Club logo

notion-py's People

Contributors

artemermulin avatar arturtamborski avatar dmtomczyk avatar drauh avatar evertheylen avatar gabrocheleau avatar guilherme-abcam avatar hmartiro avatar hoahovan avatar huksley avatar iguannalin avatar indirectlylit avatar ivanistheone avatar jamalex avatar jean avatar kevinjalbert avatar miraclexyz avatar natikgadzhi avatar nielsbom avatar samtgarson avatar snoop2head avatar ssvaddiparthy avatar tangjeff0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

notion-py's Issues

Unable to create a new row in notion database

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

record_id issue

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?

Get Collection View returning none

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

“Invalid Input” error calling a collection.

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.

notion.client.NotionValidationError: Something went wrong. (400)

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)

How to set an icon when creating a new row?

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?

Fix source in FileBlock

_______________________________ 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

PR this fork to original repo

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.

Fix Callbacks

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.

get_property() bug

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(".")

Public Announcements / Discussion Thread

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.

Click here to read more about the purpose of this ticket It should be treated as an old-style multi-page overly-lengthy forum thread containing list of not-fully-refined ideas to implement.

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.


The Grand List of Things includes:

  • ???

Collection view not functioning as documented; not returning rows

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='')>
]

CollectionRowBlock.get_all_properties() throws TypeError: 'NoneType' object is not iterable

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.