Introduce a new decorator: 'sig', which combines expose and validate in a single decorator.
This commit is contained in:
parent
7cad370657
commit
97f1b197ce
@ -1,7 +1,8 @@
|
||||
from wsme.api import expose, validate
|
||||
from wsme.api import sig, expose, validate
|
||||
from wsme.root import WSRoot
|
||||
from wsme.types import wsattr, wsproperty, Unset
|
||||
|
||||
__all__ = ['expose', 'validate',
|
||||
__all__ = [
|
||||
'expose', 'validate', 'sig',
|
||||
'WSRoot',
|
||||
'wsattr', 'wsproperty', 'Unset']
|
||||
|
11
wsme/api.py
11
wsme/api.py
@ -156,6 +156,17 @@ class expose(object):
|
||||
return func
|
||||
|
||||
|
||||
class sig(object):
|
||||
def __init__(self, return_type, *param_types, **options):
|
||||
self.expose = expose(return_type, **options)
|
||||
self.validate = validate(*param_types)
|
||||
|
||||
def __call__(self, func):
|
||||
func = self.expose(func)
|
||||
func = self.validate(func)
|
||||
return func
|
||||
|
||||
|
||||
class pexpose(object):
|
||||
def __init__(self, return_type=None, contenttype=None):
|
||||
self.return_type = return_type
|
||||
|
Loading…
x
Reference in New Issue
Block a user