You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
uses the function name to establish a route, but the say_hello decorator changes the function name to 'inner', in this case.
A quick fix on the client side is to use the functools and decorate the inner method with it, like:
Note that decorators are executed from bottom to top. Also note that decorators are syntactic sugar. The above could be rewritten as: on(other)(on_heartbeat)
As you can see on() receives other(). And in it's current implementation on() will register other in a global list of routables. Ans it sets the attributes _on_action and _skip_schema_validation on this method instead of setting them on on_heartbeat.
create_route_map() iterates over that global lists of routables. It verifies if an instance of ChargePoint has an attribute that matches the routables. So in our case something like getattr(ChargePoint(), 'other') is done. That look up will fail.
OCPP Version: 0.8.1
Python Version: 3.X
If we have an handler for a BootNotification like this:
Things work as expected. But if we have a simple decorator like this one:
and we apply it to the BootNotification handler:
The handler is not registered in the routables and we get the error:
This happens because the code in here:
ocpp/ocpp/routing.py
Line 37 in 48092b4
uses the function name to establish a route, but the say_hello decorator changes the function name to 'inner', in this case.
A quick fix on the client side is to use the functools and decorate the inner method with it, like:
But ideally, the lib should be shielded against other decorators actions
The text was updated successfully, but these errors were encountered: