lastorel / pytion

Unofficial Python client for official Notion API
GNU General Public License v3.0
44 stars 3 forks source link

May be, mistake in models.py #33

Closed tol2000 closed 2 years ago

tol2000 commented 2 years ago

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()
        }
lastorel commented 2 years ago

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 commented 2 years ago

for v1.3.1 #32 will be fixed

tol2000 commented 2 years ago

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 твой, похоже, самый крутой! Буду следить.