From c9c5b48a4daf86ee7f5e866e6f8dcd3487a6fd28 Mon Sep 17 00:00:00 2001 From: "Nicholas H.Tollervey" Date: Wed, 14 Feb 2024 10:36:38 +0000 Subject: [PATCH] Fix the goose. --- src/invent/ui/core.py | 4 ++-- static/goose.html | 4 ++-- static/goosey.py | 8 ++++---- tests/ui/test_core.py | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/invent/ui/core.py b/src/invent/ui/core.py index 7fe1b3a..f807260 100644 --- a/src/invent/ui/core.py +++ b/src/invent/ui/core.py @@ -116,13 +116,13 @@ def __set__(self, obj, value): if isinstance(value, from_datastore): def reactor(message, key=value.key): - if message.key == key: + if message._subject == key: setattr( obj, self.private_name, self.validate(message.value) ) obj.render() - invent.subscribe(reactor, to_channel="datastore", when="store") + invent.subscribe(reactor, to_channel="store-data", when=value.key) value = invent.datastore.get(value.key) setattr(obj, self.private_name, self.validate(value)) diff --git a/static/goose.html b/static/goose.html index eb71727..46079d7 100644 --- a/static/goose.html +++ b/static/goose.html @@ -28,8 +28,8 @@
- +
diff --git a/static/goosey.py b/static/goosey.py index 9c50f4a..76b3303 100644 --- a/static/goosey.py +++ b/static/goosey.py @@ -1,7 +1,7 @@ import invent from invent.ui import Button, Image, from_datastore -invent.set_media_root("static") +invent.set_media_root("/static") invent.datastore.update({ "number_of_honks": 0, "number_of_oinks": 0, @@ -81,9 +81,9 @@ def move_page(message): # Pubsub (???) -invent.pubsub.subscribe(make_honk, to_channel="honk", when=["press", "touch"]) -invent.pubsub.subscribe(make_oink, to_channel="oink", when=["press", "touch"]) -invent.pubsub.subscribe(move_page, to_channel="navigate", when=["press",]) +invent.subscribe(make_honk, to_channel="honk", when=["press", "touch"]) +invent.subscribe(make_oink, to_channel="oink", when=["press", "touch"]) +invent.subscribe(move_page, to_channel="navigate", when=["press",]) # GO! diff --git a/tests/ui/test_core.py b/tests/ui/test_core.py index 02e5cb6..1b959c8 100644 --- a/tests/ui/test_core.py +++ b/tests/ui/test_core.py @@ -437,7 +437,7 @@ def test_widget_init_defaults(): assert len(w.id[7:]) == 10 # The default position is top left. assert w.position == "TOP-LEFT" - # The default pubsub channel for widget related messages is the same as + # The default channel for widget related messages is the same as # the widget's id. assert w.channel == w.id