Open theVAX opened 9 months ago
Hello,
Thanks to the report, the Scriptor API "Module" class includes some built-in functions, which are:
These functions have a static method signature (you can check it here: https://github.com/viur-framework/viur-scriptor-api/blob/main/viur/scriptor/module.py).
The view function requires a string argument, which is the key.
from viur.scriptor.module import user
async def main():
userkey=""
auser=False
async for au in user.list({"limit":1},renderer="vi"):
auser=au
break
if auser:
print(auser)
userview = await user.view(auser["key"])
print (userview)
Hello @ciansen,
the problem here is totally different: The module access functions in the scriptor-api don't ever check on HTTP status codes.
This example here:
from viur.scriptor.module import user
async def main():
userview = await user.view("self") # works
print(userview)
userview = await user.view("lol") # 404...
print(userview)
Fails in the second case, as the api receives a JSON-parsable string containing the error message, but the status_code of 404 is never evaluated. In this case it would be correct that the result is None, and not that anything which is returned is JSON-parsed and then relied that there is a "values" key in the result.
if you call the view()-function on a generated viur module you'll get this Error:
I made a example script to demonstate it: