[FIXED] Multiple Decorators in forms

This might be a bug

If I use multiple decorators on a function within a form only the top decorator is used.

In the example below, you can see the behaviour with two decorators only executes the uppermost decorator

#name x is only wrapped in the emphasis wrapper
@emphasis
@strong
def name(x):
    return x

the workaround is to use

name = emphasis(strong(name))

https://anvil.works/build#clone:HEUXMIOEEOMIAI4A=3VHOKEYTL4RYL63P7UZCMQYG

Please see this post from Ian.

thank you - i had a look at that post - but I couldn’t adapt the answer to this situation.
What would I need to change for the two custom wrappers to work in the expected way…

Apologies if this is a different issue.

I’m on my cell phone right now so forgive the formatting.

If you use @emphasis(“name”) do you still see the issue?

I use multiple decorators often but always in server calls with anvil.sever.callable(“function_name”) as the top decorator, and this works as expected.

In any case, you may be experiencing something different.

I think it’s different because the other post is referring to @anvil_server_callable
When I try that I just get an error - str not callable

edit -
I tried doing this in the server which works:

@anvil_server_callable("name")
@emphasis
@strong
def name(x):
    return x

So it must be a problem with skulpt within a form?

1 Like

I’m on my phone too, so I haven’t tried.

Is this caused by the fact that the function name is name?

Ooh, yes, this is definitely a bug! As you have found, this problem occurs only in client code, and can be worked around as you suggest, so hopefully this shouldn’t slow you down for now – but we will get it fixed :slight_smile:

This should now be working :slight_smile:

1 Like