Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

May be, mistake in models.py #33

Closed
tol2000 opened this issue Sep 7, 2022 · 3 comments · Fixed by #36
Closed

May be, mistake in models.py #33

tol2000 opened this issue Sep 7, 2022 · 3 comments · Fixed by #36
Assignees
Labels
help wanted Extra attention is needed

Comments

@tol2000
Copy link

tol2000 commented Sep 7, 2022

Hello! Thank you for the interesting notion api object wrapper.
As I understood, class PropertyValue does not fully support images now?
But I tried to use this class in database pages and got items of Property class (I expected PropertyValue class)
Here is my code:

res = db.db_filter(property_name="Owner", value="John", property_type="select", condition='equals')
for p in res.obj:
    print(f'url: {p.url}')
    for field_name, field_property in p.properties.items():
        print(f'    {field_name}, type: {type(field_property)}')

May be, I misunderstood something, but, may be in the string 541 of models.py (fragment below) you have to wrote name: (PropertyValue(data) instead of name: (Property(data)?

self.properties = {
            name: (Property(data) if not isinstance(data, PropertyValue) else data)
            for name, data in kwargs["properties"].items()
        }
@tol2000 tol2000 changed the title May be, error in models.py May be, mistake in models.py Sep 7, 2022
@lastorel lastorel self-assigned this Sep 12, 2022
@lastorel lastorel added the question Further information is requested label Sep 12, 2022
@lastorel
Copy link
Owner

lastorel commented Sep 12, 2022

Hello, thanks for feedback.

  1. PropertyValue does not support images yet. But you can retrieve RAW data from .raw attr of the object if really needed
  2. Yeah it's well-known workaround for new API release https://developers.notion.com/changelog/releasing-notion-version-2022-06-28
    but it's realy deprecated. So you can do this for pytion v1.3.0:
    Before accessing to Page properties use method .get_page_properties() like that:
...
for p in res.obj:
    res.get_page_properties(obj=p)
    print(f'url: {p.url}')
    for field_name, field_property in p.properties.items():
        print(f'    {field_name}, type: {type(field_property)}')
...

API developers did rollback with page getting algo: https://developers.notion.com/changelog/changes-for-august-31-2022

Если короче, то ребята при релизе новой API версии сначала поменяли алгоритм выгрузки объектов Page, а потом без смены версии сделали откат.

@lastorel
Copy link
Owner

for v1.3.1 #32 will be fixed

@tol2000
Copy link
Author

tol2000 commented Sep 12, 2022

I didn't dig deep into the deeps of Notion API jsons, I learned your library, it was enough for my tasks. Objects - its cool! )
So, it was not your bug, just temp feature) Ok, I will follow your and Notion progress:), hope that will be number one Notion API object wrapper!

P.S. Приятно, что разработчик русскоязычный :) Реально из живых существующих питоновских либов по notion твой, похоже, самый крутой! Буду следить.

@tol2000 tol2000 closed this as completed Sep 12, 2022
@lastorel lastorel linked a pull request Sep 27, 2022 that will close this issue
@lastorel lastorel added help wanted Extra attention is needed and removed question Further information is requested labels Sep 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants