Open Dreamsorcerer opened 4 years ago
OK, answer to second question is await signup_form.async_check()
, which doesn't appear in the documentation, but found it in the source code.
Worth noting however, that subdict(trafaret=func)
does not use async.
subdict is a function. We need to implement async_subdict then
It was not documented possible because no one was really interested in async version.
Well, I found this project as it was being used in some aiohttp demos, so I'm probably not the only one.
Yes, but if you use trafaret for sanitising of input data then you will not need to call anything asynchronously. But of course if you need to make query to database, then you will need async version. That was my thought when I added async to trafaret. So, we probably need to update documentation then. BTW we have context argument, so you can place application object here for some deeply nested trafarets.
Yes, in fact that's exactly what I've done. I pass the request object through as the context.
I couldn't find an example of this in the documentation, so is this the expected way to run a function to validate a value?
As an extension to that, is it possible to support async functions in some way? So, that code might end up looking like: