Browse Source

[trac1010] some internal doc

Jelte Jansen 14 years ago
parent
commit
c4c85ce169
2 changed files with 14 additions and 4 deletions
  1. 0 1
      src/lib/python/isc/config/tests/ccsession_test.py
  2. 14 3
      src/lib/python/isc/log/log.cc

+ 0 - 1
src/lib/python/isc/config/tests/ccsession_test.py

@@ -610,7 +610,6 @@ class TestModuleCCSession(unittest.TestCase):
         # test whether default_logconfig_handler reacts nicely to
         # bad data. We assume the actual logger output is tested
         # elsewhere
-        #print(config_data.get_value("loggers"))
         self.assertRaises(TypeError, default_logconfig_handler);
         self.assertRaises(TypeError, default_logconfig_handler, 1);
 

+ 14 - 3
src/lib/python/isc/log/log.cc

@@ -168,7 +168,18 @@ init(PyObject*, PyObject* args) {
     Py_RETURN_NONE;
 }
 
-isc::data::ElementPtr PyObjectToElement(PyObject* obj) {
+// This function takes a PyObject* and converts it to a ConstElementPtr
+//
+// The Python object should be a basic object, i.e. a bool, long,
+// float, string, list, or dict. The contents of these lists and
+// dicts have the same limitation.
+// If any other type is encountered, an InternalError is raised.
+//
+// Note: This is a conversion between basic python types and our
+// own c++ equivalent (the Element). In that sense we may want to use it
+// in more places. If so, we should move it. It is defined here now
+// because this is the only place it is used.
+isc::data::ConstElementPtr PyObjectToElement(PyObject* obj) {
     if (PyBool_Check(obj)) {
         return isc::data::Element::create(PyObject_IsTrue(obj) == 1);
     } else if (PyLong_Check(obj)) {
@@ -213,8 +224,8 @@ logConfigUpdate(PyObject*, PyObject* args) {
     }
 
     try {
-        isc::data::ElementPtr new_config = PyObjectToElement(new_configO);
-        isc::data::ElementPtr mod_spec_e = PyObjectToElement(mod_specO);
+        isc::data::ConstElementPtr new_config = PyObjectToElement(new_configO);
+        isc::data::ConstElementPtr mod_spec_e = PyObjectToElement(mod_specO);
         isc::config::ModuleSpec mod_spec(mod_spec_e);
         isc::config::ConfigData config_data(mod_spec);
         isc::config::default_logconfig_handler("logging", new_config,