Undocumented
Function | bindable |
Mark a method as a "bindable" method. |
Function | modified |
Annotate a callable as a modified wrapper of an original callable. |
Function | named |
Change the name of a function to the given name. |
Function | original |
Get the original, user-specified name of function, chasing back any wrappers applied with modified. |
Constant | C |
Undocumented |
Mark a method as a "bindable" method.
If a Klein.app
resource is found on an instance object (i.e. is returned from YourObject().app.resource()), it will pass self from that instance to all of its routes, making a signature of 2 arguments: self and request However, if it's found globally (i.e. app = Klein(); @app.route(...) at global scope), then it will only receive one: request. However, for decorators that must be able to live between @route and the user's function, but still need to manipulate the request object, they need to be invoked with a consistent argument signature. A method decorated with @bindable will therefore always take instance, request as its first two arguments, even if instance is None when the Klein
object is not bound to an instance.
Parameters | |
bindable:C | Undocumented |
Returns | |
C | its argument, modified to mark it as unconditionally requiring an instance argument. |
Annotate a callable as a modified wrapper of an original callable.
Parameters | |
modification:str | A name for the type of modification, for example "form processor" or "request forwarder"; this will be tacked on to the name of the resulting function. |
original:Callable | Undocumented |
modifier:Optional[ | Another decorator which, if given, will be applied to the function that decorates this function. Additionally, any new attributes set on the decorated function by modifier will be copied to original. This allows attributes set by "inner" decorators such as klein.Form.handler and klein.app.Klein.route to set attributes that will be visible at the top level. |
Returns | |
Callable | A new callable; this may have a different argument signature or return value, and is only related to original in the sense that it likely calls it. |