-
Zash
Anyone happen to know about any wokkel pubsub examples I could look at?
-
ralphm
Zash: besides the ones in the repo?
-
Zash
ralphm, were there examples specific to *pubsub* that I missed?
-
ralphm
ah, crap
-
ralphm
let me see if I can point you to some
-
Zash
I got as far as making a thing that connects and subscribes to a node
-
ralphm
I have code using it, of course, e.g. in ikDisplay, but that's not really an easy example.
-
ralphm
Zash: maybe I can help you with something specific?
-
Zash
Actually, I might be a point where I'd wanna read docs on how to interact with the XML data.
-
ralphm
Zash: I assume you have implemented an itemsReceived method on your subclass of PubSubClient?
-
ralphm
Then, the only arguments is `events`, and it has an `items` attribute you can inspect
-
Zash
https://cerdale.zash.se/upload/jlSf-ddwwUkewp1n/pubsub-example.tac
-
ralphm
Right. So an item here is one of these: https://wokkel.ik.nu/documentation/current/api/wokkel.pubsub.Item.html
-
ralphm
as an Item is an Element, you can either use named attributes 'eg. item.foo, to get to the payload root named foo', or using the elements() function that returns an iterator of child elements
-
ralphm
an Element has 'name' and 'uri' attributes to inspect
-
ralphm
and you can coerce the text in an child 'bar' with `unicode(parent.bar)`
-
ralphm
Zash: does that help?
-
Zash
Yes, thanks. Finding some twisted domish docs too.
-
ralphm
https://twistedmatrix.com/documents/current/api/twisted.words.xish.domish.Element.html
-
ralphm
Zash: I had plans to actually write more documentation, but sadly that's not happened yet
-
ralphm
Zash: if you want to see typical use of domish Elements, I suggest looking at the wokkel code, where it parses things in methods typically called fromElement
-
ralphm
Zash: e.g. in data_form.py or muc.py
-
Zash
Wooh! `2019-08-30T17:39:00+0200 [stdout#info] Hello World`
-
ralphm
:-D