-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Batch call tweaks #135
base: main
Are you sure you want to change the base?
Batch call tweaks #135
Conversation
Thanks, I'll give that a try. |
@jshaffstall Did this work out ok for you? Shall we merge it? |
Sorry, end of the semester crunch here, I haven't had a chance to try this. Grades are due first of next week, I'll get a chance to try it then. |
If I have a server function that requires authentication, the order of the decorators seems to matter. This works as expected:
while this allows the call even if I'm not logged in:
I don't know if that's just a documentation issue, or something else. I also tested with a custom decorator, and it also worked only if the |
yeah this seems like an oversight on my part - i'll have a think about that and ping you for an update. I can't really see a way around this with the current api here. My initial thinking is that i'll just have to reimplement the
|
Here's the clone link for the app where I was testing these: https://anvil.works/build#clone:2J2YQGYHOHU54UEK=YCIW4AZS5UTZASCOYEASOUCN You can play with the order of decorators there. The one order does seem to work just fine, throwing the authentication exception when I'm not logged in and allowing the call when I am. |
@jshaffstall you can try the latest version now - just copy paste the note that I've removed the this makes sure that any callable that has |
While that helps with the specific case of
while this does not:
Not a big deal, as long as it's documented. You can see the working version in the clone I posted above. |
Noted. I don't really see how this example is different if you replace batched.callable with anvil.server.callable though. The behaviour differs depending on the order there too. Or am I missing something? ie @anvil.server.callable
@test_complicated_decorator
@test_complicated_decorator
@anvil.server.callable Are different in the same way as the |
As I say, the order being important isn't a big deal, but should be documented. The order being important for |
One side effect of |
Good point. Then I think the recommendation might be to duplicate rather than replace the decorator. Putting both decorators on the callable doesn't impact how the callable works. But you'll get autocompletion this way. |
So something like:
where if the |
I think the documentation would say that call signature should match exactly. batched.callable is a wrapper around anvil.server.callable. And adding 2 of them would behave in the same way as having 2 anvil.server.callable decorators. The top decorator will override the behaviour of the lower decorators. |
Ah, so this works fine:
The anvil.server.callable exists only for the autocompleter. As long as the docs have an example of more complicated usage, I think people will be fine. |
@jshaffstall
you can try this out
just paste the batcher module from this PR into a client module
then use it like this on the server
then on the client
TODO