API¶
Public API¶
wsme
– Essentials¶
- class wsme.signature([return_type, [arg0_type, [arg1_type, ..., ]]]body=None, status_code=None)[source]¶
Decorator that specify the argument types of an exposed function.
- Parameters:
return_type – Type of the value returned by the function
argN – Type of the Nth argument
body – If the function takes a final argument that is supposed to be the request body by itself, its type.
status_code – HTTP return status code of the function.
ignore_extra_args – Allow extra/unknow arguments (default to False)
Most of the time this decorator is not supposed to be used directly, unless you are not using WSME on top of another framework.
If an adapter is used, it will provide either a specialised version of this decororator, either a new decorator named @wsexpose that takes the same parameters (it will in addition expose the function, hence its name).
- class wsme.wsattr(datatype, mandatory=False, name=None, default=Unset, readonly=False)[source]¶
Complex type attribute definition.
Example:
class MyComplexType(wsme.types.Base): optionalvalue = int mandatoryvalue = wsattr(int, mandatory=True) named_value = wsattr(int, name='named.value')
After inspection, the non-wsattr attributes will be replaced, and the above class will be equivalent to:
class MyComplexType(wsme.types.Base): optionalvalue = wsattr(int) mandatoryvalue = wsattr(int, mandatory=True)
- class wsme.wsproperty(datatype, fget, fset=None, mandatory=False, doc=None, name=None)[source]¶
A specialised
property
to define typed-property on complex types. Example:class MyComplexType(wsme.types.Base): def get_aint(self): return self._aint def set_aint(self, value): assert avalue < 10 # Dummy input validation self._aint = value aint = wsproperty(int, get_aint, set_aint, mandatory=True)
- wsme.Unset¶
Default value of the complex type attributes.
- class wsme.WSRoot(protocols=[], webpath='', transaction=None, scan_api=<function scan_api>)[source]¶
Root controller for webservices.
- Parameters:
protocols – A list of protocols to enable (see
addprotocol()
)webpath – The web path where the webservice is published.
transaction (A transaction-like object or
True
.) –If specified, a transaction will be created and handled on a per-call base.
This option can be enabled along with repoze.tm2 (it will only make it void).
If
True
, the defaulttransaction
module will be imported and used.