0

I'm trying to get Brython to initialise Jasonette.

The basic JS example works. It's a trivial conversion from the example JS code into Brython. The function appears to execute (there are no errors, and there is a resulting JS object returned), but the page is blank and there are no Jasonette elements created.

I've created a JSFiddle to demonstrate this issue.

Since it's a trivial conversion of a dict to a JSON object, I would assume it might be to do with the '$' in the keys. But even then, these are quoted strings.

The most minimal example that creates a DOM element seems to be Jason({"$cell": true}, {});.

The Brython equivalent doesn't do anything.

    <script type="text/python">
        from browser import window
        Jason = window.Jason
        app = Jason({'$cell': True}, {})
    </script>
Rebs
  • 4,169
  • 2
  • 30
  • 34
  • It looks like brython passes much of the python internals through to JS. I've initialised the app in JS and am using a timer to call `document['jason']._update({...})`, and can see the st.js lib going recursive parsing the dictionary. Adding debug indicates there's many Python d-under functions in there (getitem, class, bool, etc). – Rebs Oct 11 '21 at 06:52
  • https://github.com/brython-dev/brython/issues/1433 Looks like Brython dicts are not clean. I'm not sure what to do to fix this. – Rebs Oct 11 '21 at 07:08
  • It seems this is due to cell.js looking into the root context for JS Objects with "$cell: true" set. Being inside brython, this isn't true. Using `window.app = Jason(...)` also doesn't seem to fix this since Brython onload is executed after cell.js does its scan. A [fork of cell.js](https://github.com/lesichkovm/cell) exists which can be updated via events but it doesn't resolve the issue with trying to initialise Jason. It may just be that these libraries need re-writing in Brython to really work. – Rebs Oct 18 '21 at 07:34

0 Answers0