Skip to content

Commit

Permalink
Finalize HttpPattern object and its converter to werkzeug.routing.Rule.
Browse files Browse the repository at this point in the history
  • Loading branch information
plq committed Oct 28, 2012
1 parent 08342c5 commit 1887864
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion spyne/_base.py
Expand Up @@ -348,7 +348,7 @@ def __init__(self, function, in_message, out_message, doc,
various elements of the request protocol.
Currently, the only object supported here is the
:class:`spyne.protocol.http.HttpRoute` object.
:class:`spyne.protocol.http.HttpPattern` object.
"""

@property
Expand Down
21 changes: 10 additions & 11 deletions spyne/protocol/http.py
Expand Up @@ -40,7 +40,6 @@

from spyne.protocol.dictobj import DictObject


def get_stream_factory(dir=None, delete=True):
def stream_factory(total_content_length, filename, content_type,
content_length=None):
Expand Down Expand Up @@ -158,27 +157,27 @@ def create_out_string(self, ctx, out_string_encoding='utf8'):
ctx.out_string = ctx.out_document


class HttpRoute(object):
class HttpPattern(object):
"""Experimental. Stay away.
:param address: Address pattern
:param verb: HTTP Verb pattern
:param host: HTTP "Host:" header pattern
"""

def __init__(self, address, verb=None, host=None):
def __init__(self, address, verb=None, host=None, endpoint=None):
self.address = address
self.host = host
self.verb = verb
self._callable = None
self.endpoint = endpoint

def for_werkzeug(self):
def as_werkzeug_rule(self):
from werkzeug.routing import Rule
from spyne.util.invregex import invregex

if self.verb is None:
for v in invregex(self.verb):
yield Rule(self.address, host=self.host, endpoint=self._callable,
verb=v)
else:
yield Rule(self.address, host=self.host, endpoint=self._callable)
methods = None
if self.verb is not None:
methods = invregex(self.verb)

return Rule(self.address, host=self.host, endpoint=self.endpoint,
methods=methods)
3 changes: 3 additions & 0 deletions spyne/service.py
Expand Up @@ -55,6 +55,9 @@ def __init__(self, cls_name, cls_bases, cls_dict):
else:
self.__has_aux_methods = True

for p in descriptor.patterns:
p.endpoint = k

def __get_base_event_handlers(self, cls_bases):
handlers = {}

Expand Down

0 comments on commit 1887864

Please sign in to comment.