Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Request: Make JustPy more reactive

See original GitHub issue

Please forgive my ramblings below. I know what I’d like to see but don’t know whether they are feasible.

First some shortcomings in the current implementation of models/bindings in JustPy:

  • Setting the model as model=[wp, ‘text’] is not very descriptive. It suggests that more items can be provided (could it?). At least using a tuple conveys more clearly that it is unchangeable. I’d prefer something more verbose model=dict(owner=wp, prop=‘text’) or maybe even model=‘wp.text’.
  • In Vue one can use more data bindings than just the model (but the model is two-way). Multiple arguments can be bound to data with the “:”, as in :icon=“some_object.icon”. Maybe something like this could be extended to components arguments in JustPy. Something along the lines of model={‘owner’: wp, ‘text’:‘text’, ‘icon’:‘preferred_icon’). Or maybe even bindings={‘text’: ‘wp.text’, ‘icon’:‘wp.preferred_icon’}

Then, a wish: One thing I liked about using Vue (+Quasar) was the way to have the components adjust themselves to changes in data. For example, say I want a list of items and I want to be able to filter that list of items. The user enters some filter criteria (through a search box or check boxes. Then I’d construct the list like so:

          <q-item v-for="service in filteredServices" :key="service.uuid"
                  :to="{name: 'service_details', params: { uuid: service.uuid }}"
              {{ service.path }}

where the filtered list would be a computed data property:

  export default {
    data () {
      return {
        services: [],
        filterText: ''

    computed: {
      filteredServices () {
        return => {
          const path = el.path.toLowerCase()
          return path.indexOf(this.filterText.toLowerCase()) !== -1

(the services data property would be fetched from the server).

The big advantage of all this is that the list would automatically adjust if any of the underlying data changes (ie the filtered list changed due to the user entering filter criteria). With JustPy I can’t see another way of detecting the change in filter criteria, remove the old list components, construct a new component list based on the newly filtered data, insert that component list into the page. It works but feels clumsy because you have to manually manipulate the components (old and new).

Anyway I hope the above makes any sense.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

mjmarecommented, Apr 27, 2020

I think that would work but it feels less clean as the Vue way of doing things. I think it leads to spaghetti code in real programs.

Since I posted this issue I have experimented with custom components, and that cleans up the code immensely. One of the advantages of the Vue style is that one does not have to keep references to the components around in order to manipulate them later. Especially when one use deeply nested structures (eg a List with Items Which contain Sections which contain Text and Avatars etc etc etc). When one uses custom components the state is “local” (available through self) and its representation (the HTML components) is also “local”. By using the react method makes the representation “follow” the state. Much more elegant. (Don’t know if this paragraph makes any sense to you). So, in conclusion, IMHO JustPy is not reactive in the Vue sense, but the need is less due to the ease of use of custom components. But this needs a very different way of thinking. More articles on how to structure programs in a JustPythonic way would be very welcome.

giodegascommented, Feb 2, 2021

I improved the efficiency of my app now, reducing the amount of data exchanged, The first prototype was quite abusive. But I am afraid that scaling the application, the problem may come back. Thank you, anyway.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reactivity in JustPy
A web framework is reactive if it updates the view whenever the some underlying data in the application changes. In practice, what this...
Read more >
Advanced Components - JustPy
An object-oriented, component based, high-level Python Web Framework that requires no front-end programming.
Read more >
Creating Your Own Components - JustPy
The idea behind component programming is simple and compelling: Build a component once, and then reuse it either in the same application or...
Read more >
WebPage class - JustPy
The WebPage class is used to instantiate web pages. A JustPy request handler must always return an instance of this class or of...
Read more >
The Request Object - JustPy
An object-oriented, component based, high-level Python Web Framework that requires no front-end programming.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found