jdev - 2019-08-30


  1. Zash

    Anyone happen to know about any wokkel pubsub examples I could look at?

  2. ralphm

    Zash: besides the ones in the repo?

  3. Zash

    ralphm, were there examples specific to *pubsub* that I missed?

  4. ralphm

    ah, crap

  5. ralphm

    let me see if I can point you to some

  6. Zash

    I got as far as making a thing that connects and subscribes to a node

  7. ralphm

    I have code using it, of course, e.g. in ikDisplay, but that's not really an easy example.

  8. ralphm

    Zash: maybe I can help you with something specific?

  9. Zash

    Actually, I might be a point where I'd wanna read docs on how to interact with the XML data.

  10. ralphm

    Zash: I assume you have implemented an itemsReceived method on your subclass of PubSubClient?

  11. ralphm

    Then, the only arguments is `events`, and it has an `items` attribute you can inspect

  12. Zash

    https://cerdale.zash.se/upload/jlSf-ddwwUkewp1n/pubsub-example.tac

  13. ralphm

    Right. So an item here is one of these: https://wokkel.ik.nu/documentation/current/api/wokkel.pubsub.Item.html

  14. 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

  15. ralphm

    an Element has 'name' and 'uri' attributes to inspect

  16. ralphm

    and you can coerce the text in an child 'bar' with `unicode(parent.bar)`

  17. ralphm

    Zash: does that help?

  18. Zash

    Yes, thanks. Finding some twisted domish docs too.

  19. ralphm

    https://twistedmatrix.com/documents/current/api/twisted.words.xish.domish.Element.html

  20. ralphm

    Zash: I had plans to actually write more documentation, but sadly that's not happened yet

  21. 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

  22. ralphm

    Zash: e.g. in data_form.py or muc.py

  23. Zash

    Wooh! `2019-08-30T17:39:00+0200 [stdout#info] Hello World`

  24. ralphm

    :-D