ianb
June 22, 2022, 8:35pm
3
Going down the rabbit hole linkie trail led me to this post, where Phil and Stefano figured out how to access app data semi programmatically if you have lots of apps:
Holy smokes! I haven’t seen this documented anywhere, so I suppose it’s subject to change without notice. I would also expect that this only works after you successfully log in as an Anvil user. Even so…
I tried the 1st link, got a JSON listing of all of my apps! That’s incredibly helpful.
I wasn’t sure how to use the 2nd link. But if you append the app’s “id” (from the 1st link) immediately after the trailing “/”, the response is a copy of the corresponding app as a .yaml file. In a br…
But I think you might end up having to build an uplink script to build the answer to what you are looking for, I’m sure the new .disconnect()
feature might help.
I forgot how easy this is now:
import anvil.server
from contextlib import contextmanager
@contextmanager
def open_anvil_connection(uplink_key):
anvil.server.connect(uplink_key)
print("Connected to Anvil")
yield
anvil.server.disconnect()
print("Disconnected from Anvil")
Thats it.
Now you can use:
with open_anvil_connection(my_uplink_key):
stuff = anvil.server.call("some_remote_function")
results = blah_blah_do_crunchy_crunchy_on_stuff(stuff)
anvil.server.ca…
1 Like