BIND 10 trac2298_7, updated. 3e089a516107add7d48a7b8d2007bc39819bc5a9 [2298_7] add comments about checking each 'item' element under the root element
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Nov 6 12:43:46 UTC 2012
The branch, trac2298_7 has been updated
via 3e089a516107add7d48a7b8d2007bc39819bc5a9 (commit)
via 420b58ce70f1cc0a81adef6fccbd5b6ee394bf0c (commit)
via ac646067077f60b99e70153e9896e2e7062f080c (commit)
via a5ab418844921713e64d801f7956cd9c136b5df8 (commit)
via 5e849dc00862135e87b39dfc458ce6779a0b2945 (commit)
via f0ab6da7caee442a7335b7e503591ad4a3d43283 (commit)
from f5caa308b4534eb70cd5996c2e809a36ac36ee6d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 3e089a516107add7d48a7b8d2007bc39819bc5a9
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Tue Nov 6 21:22:33 2012 +0900
[2298_7] add comments about checking each 'item' element under the root element
commit 420b58ce70f1cc0a81adef6fccbd5b6ee394bf0c
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Tue Nov 6 21:12:45 2012 +0900
[2298_7] remove find() so that each element 'item' under the root element is checked
(actually this test wasn't run.)
commit ac646067077f60b99e70153e9896e2e7062f080c
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Tue Nov 6 21:01:31 2012 +0900
[2298_7] use with-statement instead of try-except-finally statement
commit a5ab418844921713e64d801f7956cd9c136b5df8
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Tue Nov 6 21:37:43 2012 +0900
[2298_7] add an example of the path in docstring of xml_handler()
commit 5e849dc00862135e87b39dfc458ce6779a0b2945
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Tue Nov 6 21:40:11 2012 +0900
[2298_7] add comments about preparation of the requested path,
regarding the condition that it is started with XM_URL_PATH + '/'
commit f0ab6da7caee442a7335b7e503591ad4a3d43283
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Tue Nov 6 20:40:43 2012 +0900
[2298_7] add description about evaluating the requested path in each if-condition
-----------------------------------------------------------------------
Summary of changes:
src/bin/stats/stats_httpd.py.in | 22 ++++++++++++++++------
src/bin/stats/tests/b10-stats-httpd_test.py | 8 +++++++-
2 files changed, 23 insertions(+), 7 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/stats/stats_httpd.py.in b/src/bin/stats/stats_httpd.py.in
index 65166bb..e76bcbe 100644
--- a/src/bin/stats/stats_httpd.py.in
+++ b/src/bin/stats/stats_httpd.py.in
@@ -122,15 +122,27 @@ class HttpHandler(http.server.BaseHTTPRequestHandler):
req_path = urllib.parse.urlsplit(req_path).path
req_path = urllib.parse.unquote(req_path)
body = None
+ # In case that the requested path (req_path),
+ # e.g. /bind10/statistics/Auth/, is started with
+ # XML_URL_PATH + '/'
if req_path.find('%s/' % XML_URL_PATH) == 0:
+ # remove './' from the path if there is
req_path = os.path.normpath(req_path)
+ # get the strings tailing after XML_URL_PATH
req_path = req_path.lstrip('%s/' % XML_URL_PATH)
+ # remove empty dir names from the path if there are
path_dirs = req_path.split('/')
path_dirs = [ d for d in filter(None, path_dirs) ]
req_path = '/'.join(path_dirs)
+ # pass the complete requested path,
+ # e.g. Auth/queries.upd, to xml_handler()
body = self.server.xml_handler(req_path)
+ # In case that the requested path (req_path) is exactly
+ # matched with XSD_URL_PATH
elif req_path == XSD_URL_PATH:
body = self.server.xsd_handler()
+ # In case that the requested path (req_path) is exactly
+ # matched with XSL_URL_PATH
elif req_path == XSL_URL_PATH:
body = self.server.xsl_handler()
else:
@@ -468,7 +480,8 @@ class StatsHttpd:
using the functions get_stats_data and get_stats_spec
respectively and loads the XML template file and returns the
string of the XML document.The argument is a path in the
- requested URI."""
+ requested URI. For example, the path is assumed to be like
+ ${module_name}/${top_level_item_name}/${second_level_item_name}/..."""
dirs = [ d for d in path.split("/") if len(d) > 0 ]
module_name = None
@@ -555,15 +568,12 @@ class StatsHttpd:
string variable and returns string. Template object includes
the variable. Limitation of a file size isn't needed there. XXXX"""
lines = None
- f = None
try:
- f = open(file_name, 'r')
- lines = "".join(f.readlines())
+ with open(file_name, 'r') as f:
+ lines = "".join(f.readlines())
except IOError as err:
raise StatsHttpdDataError(
"%s: %s" % (err.__class__.__name__, err))
- finally:
- if f: f.close()
return string.Template(lines)
if __name__ == "__main__":
diff --git a/src/bin/stats/tests/b10-stats-httpd_test.py b/src/bin/stats/tests/b10-stats-httpd_test.py
index 33c4d54..85e65e2 100644
--- a/src/bin/stats/tests/b10-stats-httpd_test.py
+++ b/src/bin/stats/tests/b10-stats-httpd_test.py
@@ -253,11 +253,17 @@ class TestHttpHandler(unittest.TestCase):
'<?xml-stylesheet type="text/xsl" href="' +
stats_httpd.XSL_URL_PATH
+ '"?>'))
- for elem in root.find('item'):
+ for elem in root:
attr = elem.attrib
value = isc.cc.data.find(DUMMY_DATA, attr['identifier'])
+ # No 'value' attribute should be found in the 'item'
+ # element when datatype of the value is list or dict.
if type(value) is list or type(value) is dict:
self.assertFalse('value' in attr)
+ # The value of the 'value' attribute should be checked
+ # after casting it to string type if datatype of the
+ # value is int or float. Because attr['value'] returns
+ # string type even if its value is int or float.
elif type(value) is int or type(value) is float:
self.assertEqual(attr['value'], str(value))
else:
More information about the bind10-changes
mailing list