Skip to content

Commit

Permalink
Added _patterns argument to @srpc and patterns attribute to MethodDes…
Browse files Browse the repository at this point in the history
…criptor.
  • Loading branch information
plq committed Oct 27, 2012
1 parent c6fb96c commit 08342c5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
10 changes: 9 additions & 1 deletion spyne/_base.py
Expand Up @@ -278,7 +278,7 @@ def __init__(self, function, in_message, out_message, doc,
is_callback=False, is_async=False, mtom=False, in_header=None,
out_header=None, faults=None,
port_type=None, no_ctx=False, udp=None, class_key=None,
aux=None):
aux=None, patterns=None):

self.__real_function = function
"""The original callable for the user code."""
Expand Down Expand Up @@ -343,6 +343,14 @@ def __init__(self, function, in_message, out_message, doc,
are ignored by the rpc layer.
"""

self.patterns = patterns
"""This list stores patterns which will match this callable using
various elements of the request protocol.
Currently, the only object supported here is the
:class:`spyne.protocol.http.HttpRoute` object.
"""

@property
def name(self):
"""The public name of the function. Equals to the type_name of the
Expand Down
11 changes: 10 additions & 1 deletion spyne/decorator.py
Expand Up @@ -200,6 +200,8 @@ def explain_method(*args, **kwargs):
_no_ctx = kparams.get('_no_ctx', True)
_udp = kparams.get('_udp', None)
_aux = kparams.get('_aux', None)
_pattern = kparams.get("_pattern",None)
_patterns = kparams.get("_patterns",[])

_faults = None
if ('_faults' in kparams) and ('_throws' in kparams):
Expand All @@ -219,11 +221,18 @@ def explain_method(*args, **kwargs):

doc = getattr(f, '__doc__')

if _pattern is not None and _patterns != []:
raise ValueError("only one of '_pattern' and '__patterns' "
"arguments should be given")

if _pattern is not None:
_patterns = [_pattern]

retval = MethodDescriptor(f,
in_message, out_message, doc, _is_callback, _is_async,
_mtom, _in_header, _out_header, _faults,
port_type=_port_type, no_ctx=_no_ctx, udp=_udp,
class_key=function_name, aux=_aux)
class_key=function_name, aux=_aux, patterns=_patterns)

return retval

Expand Down

0 comments on commit 08342c5

Please sign in to comment.