Skip to content

Commit

Permalink
check_validator -> set_validator in ProtocolBase
Browse files Browse the repository at this point in the history
  • Loading branch information
plq committed Dec 23, 2011
1 parent 600e8d4 commit ab9d613
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Expand Up @@ -5,6 +5,7 @@ Changelog
rpclib-2.5.1-beta
-----------------
* Switched to magic cookie constants instead of strings in protocol logic.
* check_validator -> set_validator in ProtocolBase

rpclib-2.5.0-beta
-----------------
Expand Down
10 changes: 6 additions & 4 deletions src/rpclib/protocol/_base.py
Expand Up @@ -36,6 +36,7 @@
from rpclib.const.http import HTTP_404
from rpclib.const.http import HTTP_413
from rpclib.const.http import HTTP_500

from rpclib.error import ResourceNotFoundError
from rpclib.error import RequestTooLongError
from rpclib.error import Fault
Expand Down Expand Up @@ -71,8 +72,7 @@ def __init__(self, app=None, validator=None):

self.set_app(app)
self.event_manager = EventManager(self)
self.validator = validator
self.check_validator()
self.set_validator(validator)

@property
def app(self):
Expand Down Expand Up @@ -179,8 +179,10 @@ def fault_to_http_response_code(self, fault):
else:
return HTTP_500

def check_validator(self):
def set_validator(self, validator):
"""You must override this function if your protocol supports validation.
"""

assert self.validator is None
assert validator is None

self.validator = None
7 changes: 4 additions & 3 deletions src/rpclib/protocol/http.py
Expand Up @@ -43,10 +43,11 @@ def _get_http_headers(req_env):
return retval

class HttpRpc(ProtocolBase):
"""The so-called ReST-minus-the-verbs HttpRpc protocol implementation.
"""The so-called REST-minus-the-verbs HttpRpc protocol implementation.
It only works with the http server (wsgi) transport.
It only parses GET requests where the whole data is in the 'QUERY_STRING'.
It only parses requests where the whole data is in the 'QUERY_STRING', i.e.
the part after '?' character in a URI string.
"""

def check_validator(self):
Expand All @@ -66,8 +67,8 @@ def decompose_incoming_envelope(self, ctx):
ctx.in_header_doc = _get_http_headers(ctx.in_document)
ctx.in_body_doc = parse_qs(ctx.in_document['QUERY_STRING'])

logger.debug('body : %r' % (ctx.in_body_doc))
logger.debug('header : %r' % (ctx.in_header_doc))
logger.debug('body : %r' % (ctx.in_body_doc))

def dict_to_object(self, doc, inst_class):
flat_type_info = inst_class.get_flat_type_info(inst_class)
Expand Down

0 comments on commit ab9d613

Please sign in to comment.