omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    ui.dump_view - why custom properties not preserved?

    Pythonista
    properties custom dumpview
    1
    2
    1814
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Phuket2
      Phuket2 last edited by

      @omz, just wondering why custom properties are not retained when you use ui.dump_view. Maybe a security injection thing, I am not sure.
      But the reason I bring it up because I was thinking about my voting app again today. My idea with the voting app was to have the client talk to say something like a Flask app, to get and post data. Then the client would understand how to render the data in a form that the client understands.
      But then I thought of another idea. What if you could design any form in the ui Designer and using ui.dump_view upload it to my flask app. So when you query your flask app and choose a survey/vote/recipe etc... your UIFile is returned as a json_str, which then can be used to recreate the form in the client(Pythonista). But to make the client code as dumb as possible, you need to be able to do specify some things in the ui Designer. I was thinking the Custom properties could have helped the client code to generically understand what data it should post back for the form. So the meaning being that most the work could be done in the form creation, and the client code could generically work out what data to post back to the flask app.
      Another thing that could help is the ability to use the hidden attr in the ui Designer. As far as I know you cant do that. But it could help fudging some things. Like a hidden label that contains the form name or whatever. (Hmmmm maybe this can be just done also using the alpha)
      Anyway, its just a thought. But seems to me, this could be an interesting idea. The UIFile having enough embedded information, it can be downloaded and a simple client class/function could present it and post the data collected back to the web app.

      1 Reply Last reply Reply Quote 0
      • Phuket2
        Phuket2 last edited by

        Lol, ok I can see this topic generated as much interest as watching grass grow :).
        But at least to give something visual, i did the below. Just using a static form here with no chance to give feedeback because the form is just sitting as a json file in a github repo. Baby steps :)
        I still like the idea/concept though. Maybe I am alone on this one! Again, this not what I described above. I just thought If i could do a static example, may give it more context. BTW, the recipe in the example is real and fantastic. It was from YouTube, I should have put the link in, but again this is just an example. No interaction is possible with this simple example. But I think you could see how there could be.

        import ui
        import requests
        import json
        
        _form_raw_url = '''https://raw.githubusercontent.com/Phuket2/ui_forms/master/MicrowaveEggRecipe.json'''
        
        resp = requests.get(_form_raw_url, timeout=5)
        if resp.status_code != 200:
            resp.raise_for_status()
        
        
        def close_action(sender):
            sender.superview.close()
        
        v = ui.load_view_str(json.dumps(resp.json()))
        if v["_dismiss"]:
            v["_dismiss"].action = close_action
        v.present('sheet')
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Powered by NodeBB Forums | Contributors