Comments (5)
I'm using the above snippet along with monitor=True, start_monitoring=True
for NotionClient
(like mentioned here #139 by @ekopach) and it reports cards that didn't change.
Changing only Card 3:
The record's title is now: Card 3F
Here's what was changed:
[('change', ['properties', 'title', 0, 0], ('Card 3', 'Card 3F'))]
The record's title is now: Card 1
Here's what was changed:
[('add', '', [('shard_id', 439132)]), ('add', '', [('space_id', '027dab3e-b3fa-43b9-b75a-90e21b39951d')])]
The record's title is now: Card 2
Here's what was changed:
[('add', '', [('shard_id', 439132)]), ('add', '', [('space_id', '027dab3e-b3fa-43b9-b75a-90e21b39951d')])]
The record's title is now: Card 3F
Here's what was changed:
[('add', '', [('shard_id', 439132)]), ('add', '', [('space_id', '027dab3e-b3fa-43b9-b75a-90e21b39951d')])]
The record's title is now: Card 1
Here's what was changed:
[('remove', '', [('shard_id', 439132)]), ('remove', '', [('space_id', '027dab3e-b3fa-43b9-b75a-90e21b39951d')])]
The record's title is now: Card 2
Here's what was changed:
[('remove', '', [('shard_id', 439132)]), ('remove', '', [('space_id', '027dab3e-b3fa-43b9-b75a-90e21b39951d')])]
The record's title is now: Card 3F
Here's what was changed:
[('remove', '', [('shard_id', 439132)]), ('remove', '', [('space_id', '027dab3e-b3fa-43b9-b75a-90e21b39951d')])]
Am I using notion-py incorrectly or is this a current issue?
I saw in the readme that it says
(Note: Notion->Python automatic updating is currently broken and hence disabled by default; call my_block.refresh() to update, in the meantime, while monitoring is being fixed)
I'd appreciate more info on this. Thanks a lot!
from notion-py.
Note: I also tried just calling add_callback(my_callback) instead of calling the my_callback function but then it simply doesn't return anything and ends.
That would be the correct usage. The way it's coded in the sample is immediately executing your callbacks in the loop (which is why you see all of them printed).
In terms of it exiting at the end, you need to do something to keep the process alive (because otherwise the watcher thread dies with your main Python thread). This could either be a loop with time.sleep(<n>)
, or simply an input()
at the end of the file, so that it will keep the process going until you hit enter or CTRL-C.
This works for me:
from notion.client import *
token_v2 = "<token>"
client = NotionClient(token_v2=token_v2)
def watch_completed_milestones():
cv = client.get_collection_view(
"https://www.notion.so/learningequality/e91d78e05fcc445a99ebbabe5c54428a?v=aafe1755187343d2a2b5b03d36f2a6c4"
)
def my_callback(record):
print("The record's title is now:", record.title)
for block_row in cv.collection.get_rows():
print("Adding callback for:", block_row.title)
block_row.add_callback(my_callback)
watch_completed_milestones()
print("Ready and watching!")
input()
Let me know how it goes!
from notion-py.
Thanks, ill try it out. You might be interested to know that there’s a few of us developer focused notion users here on slack. https://www.notion.so/notionhacks/Notion-Hacks-27b92f71afcd4ae2ac9a4d14fef0ce47
from notion-py.
And amazing job with this! I use it daily!
from notion-py.
Thanks for the heads up, I've joined the Slack team!
from notion-py.
Related Issues (20)
- HTTPERROR using children.add_new
- collection.add_row() fails on new databases HOT 2
- How to set database column calculation?
- Not documented: how to set the size of an image HOT 1
- > this is a pretty paralyzing issue. does anyone know how long it will take for it to get merged in? HOT 1
- Uploading image doesn't work HOT 2
- Need to cut a new release
- Notion crashes when setting CollectionView filter with no id HOT 2
- Is this module still work now? I got an error, outdated? HOT 1
- Failed To Run "setup.py" Due To Encoding Error
- requests.exceptions.HTTPError: Invalid input from client.get_block HOT 8
- Unsaved transactions: SpaceShardRecordPointer have no space id HOT 1
- raise InvalidNotionIdentifier(input_value)
- Help!!! requests.exceptions.HTTPError: Invalid input. HOT 4
- TypeError: Retry.__init__() got an unexpected keyword argument 'method_whitelist' HOT 3
- Client POST generates a HTTPError HOT 1
- (question) is there `get_all_comments`? HOT 1
- notion_client.errors.RequestTimeoutError: Request to Notion API has timed out
- HTTPError (400) when trying to load a database despite trying proposed solutions HOT 3
- Search (and find best matching page titles)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from notion-py.