Good day 👋
I am making a Python-based Appwrite function and I see that generally, this is done by accepting a file structured like this:
def main(context): return context.res.send("Hello World")
I was wondering if there is any information on what type/structure this "context" object has? Can it perhaps be imported from an SDK of be defined somewhere? I would love to know this for creating tests.
@ideclon thanks for the response. I already saw this page and guess I should have formulated the question differently.
Is there some Python definition of the context object? I.e. such that I can make a script like this:
def main(context: RuntimeContext):
return context.res.send("")```
In other words; this context object must have some class or data structure which is not specified in the documentation. This is relevant because I might want to write unittests that send such a context object, preferably without mocking an implementation and rather using the actual thing.
Python SDK doesn't have types, but there is a open issue an PR to implement it: https://github.com/appwrite/sdk-for-python/issues/43
Looking the PR seems like it doesn't include types for the context, you can comment the issue giving your feedback
We've been wanting to add better type support for open runtimes...not sure when we'll be able t oget to it
Alright, thanks for the info!
Just for future reference, I found the Context
object definition here https://github.com/open-runtimes/open-runtimes/blob/main/runtimes/python-3.10/src/server.py#L47-L70
This is what I was looking for 😀 thx again for the pointers
[SOLVED] Python context object
Recommended threads
- HTTP POST to function returning "No Appw...
Hi everyone, I’m running into an issue with my self-hosted Appwrite instance. I’ve set up my environment variables (APPWRITE_FUNCTION_PROJECT_ID, APPWRITE_FUNC...
- Can't add dart 3.5 runtime
Modified the `.env` to enable dart 3.5 runtime on my self-hosted instance but still can't find the runtime when creating a new function. I manually pulled the i...
- How to verify an user using AppWrite Fun...
I have seen similar questions but none whose solutions serve me. I have a function to verify a user with their secret and their id: https://blahblah.appwrite.gl...