From 23b2874cdb60fd83fa2a6f7eb93180c502539b25 Mon Sep 17 00:00:00 2001 From: Christophe de Vienne Date: Fri, 14 Oct 2011 11:53:14 +0200 Subject: [PATCH] expose now takes extra options that can be used by the protocols --- wsme/controller.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wsme/controller.py b/wsme/controller.py index 78bf1bb..7dc1495 100644 --- a/wsme/controller.py +++ b/wsme/controller.py @@ -101,6 +101,9 @@ class FunctionDefinition(object): #: Path of the function in the api tree. self.path = None + #: Dictionnary of protocol-specific options. + self.extra_options = {} + @classmethod def get(cls, func): """ @@ -152,13 +155,15 @@ class expose(object): def getint(self): return 1 """ - def __init__(self, return_type=None): + def __init__(self, return_type=None, **options): self.return_type = return_type + self.options = options register_type(return_type) def __call__(self, func): fd = FunctionDefinition.get(func) fd.return_type = self.return_type + fd.extra_options = self.options return func @@ -232,7 +237,7 @@ class WSRoot(object): of a protocol. """ if isinstance(protocol, str): - protocol = getprotocol(protocol, options) + protocol = getprotocol(protocol, **options) self.protocols[protocol.name] = protocol protocol.root = weakref.proxy(self)