From a68b4498b87cbc8fc6f1c1c660df5fac09ca564e Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Tue, 26 Jun 2012 15:36:59 +1200 Subject: [PATCH] Allow naked value literal for pathoc path specifications. --- libpathod/pathod.py | 10 +++++----- libpathod/rparse.py | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/libpathod/pathod.py b/libpathod/pathod.py index d48697508..a09d3594c 100644 --- a/libpathod/pathod.py +++ b/libpathod/pathod.py @@ -9,6 +9,9 @@ class PathodError(Exception): pass class PathodHandler(tcp.BaseHandler): wbufsize = 0 sni = None + def debug(self, s): + logging.debug("%s:%s: %s"%(self.client_address[0], self.client_address[1], str(s))) + def handle_sni(self, connection): self.sni = connection.get_servername() @@ -20,7 +23,7 @@ class PathodHandler(tcp.BaseHandler): self.server.ssloptions["keyfile"], ) except tcp.NetLibError, v: - logging.debug("%s: %s"%(self.client_address, str(v))) + self.debug(v) self.finish() while not self.finished: @@ -61,10 +64,7 @@ class PathodHandler(tcp.BaseHandler): headers = headers.lst, sni = self.sni, remote_address = self.client_address, - #full_url = self.request.full_url(), - #query = self.request.query, httpversion = httpversion, - #uri = self.request.uri, ) self.server.add_log(dict(request=request_log, response=response_log)) else: @@ -78,7 +78,7 @@ class PathodHandler(tcp.BaseHandler): version.NAMEVERSION ) app.serve(req, self.wfile) - logging.debug("%s: wsgi %s %s"%(self.client_address, method, path)) + self.debug("%s %s"%(method, path)) class Pathod(tcp.TCPServer): diff --git a/libpathod/rparse.py b/libpathod/rparse.py index bb45ae003..6306f7461 100644 --- a/libpathod/rparse.py +++ b/libpathod/rparse.py @@ -293,6 +293,8 @@ class Body: class Path: def __init__(self, value): + if isinstance(value, basestring): + value = ValueLiteral(value) self.value = value def accept(self, settings, r): @@ -300,7 +302,7 @@ class Path: @classmethod def expr(klass): - e = Value.copy() + e = v_naked_literal.copy() return e.setParseAction(lambda x: klass(*x))