GithubHelp home page GithubHelp logo

Comments (5)

gubikmic avatar gubikmic commented on July 28, 2024 1

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.

jamalex avatar jamalex commented on July 28, 2024

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.

heyflorin avatar heyflorin commented on July 28, 2024

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.

heyflorin avatar heyflorin commented on July 28, 2024

And amazing job with this! I use it daily!

from notion-py.

jamalex avatar jamalex commented on July 28, 2024

Thanks for the heads up, I've joined the Slack team!

from notion-py.

Related Issues (20)

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.