Parcourir la source

[trac736] fix after merge

Jelte Jansen il y a 14 ans
Parent
commit
1ef6e04be1

+ 7 - 5
src/lib/config/ccsession.cc

@@ -455,10 +455,11 @@ ModuleCCSession::fetchRemoteSpec(const std::string& module, bool is_filename) {
         return (readModuleSpecification(module));
     } else {
         // It's module name, request it from config manager
-        ConstElementPtr cmd = Element::fromJSON("{ \"command\": ["
-                                                "\"get_module_spec\","
-                                                "{\"module_name\": \"" + 
-                                                spec_name + "\"} ] }");
+
+        // Send the command
+        ConstElementPtr cmd(createCommand("get_module_spec",
+                            Element::fromJSON("{\"module_name\": \"" + module +
+                                              "\"}")));
         unsigned int seq = session_.group_sendmsg(cmd, "ConfigManager");
         ConstElementPtr env, answer;
         session_.group_recvmsg(env, answer, false, seq);
@@ -482,7 +483,8 @@ ModuleCCSession::fetchRemoteSpec(const std::string& module, bool is_filename) {
 std::string
 ModuleCCSession::addRemoteConfig(const std::string& spec_name,
                                  void (*handler)(const std::string& module,
-                                          ConstElementPtr),
+                                                 ConstElementPtr,
+                                                 const ConfigData&),
                                  bool spec_is_filename)
 {
     // First get the module name, specification and default config

+ 11 - 10
src/lib/config/config_data.cc

@@ -49,6 +49,16 @@ find_spec_part(ConstElementPtr spec, const std::string& identifier) {
     while(sep != std::string::npos) {
         std::string part = id.substr(0, sep);
 
+        while (spec_part->getType() == Element::map && 
+               (spec_part->contains("list_item_spec") ||
+                spec_part->contains("map_item_spec"))) {
+            if (spec_part->contains("list_item_spec")) {
+                std::cout << "[XX] traversing list item " << id << std::endl;
+                spec_part = spec_part->get("list_item_spec");
+            } else {
+                spec_part = spec_part->get("map_item_spec");
+            }
+        }
         if (spec_part->getType() == Element::list) {
             bool found = false;
             BOOST_FOREACH(ConstElementPtr list_el, spec_part->listValue()) {
@@ -67,16 +77,6 @@ find_spec_part(ConstElementPtr spec, const std::string& identifier) {
         }
         id = id.substr(sep + 1);
         sep = id.find("/");
-
-        while (spec_part->getType() == Element::map && 
-               (spec_part->contains("list_item_spec") ||
-                spec_part->contains("map_item_spec"))) {
-            if (spec_part->contains("list_item_spec")) {
-                spec_part = spec_part->get("list_item_spec");
-            } else {
-                spec_part = spec_part->get("map_item_spec");
-            }
-        }
     }
     if (id != "" && id != "/") {
         if (spec_part->getType() == Element::list) {
@@ -112,6 +112,7 @@ find_spec_part(ConstElementPtr spec, const std::string& identifier) {
             }
         }
     }
+    std::cout << "[XX] RETURNING SPEC PART FOR '" << identifier << "': " << spec_part->str() << std::endl;
     return (spec_part);
 }
 

+ 7 - 0
src/lib/config/tests/config_data_unittests.cc

@@ -56,9 +56,16 @@ TEST(ConfigData, getValue) {
     EXPECT_EQ("a", cd.getValue(is_default, "value5")->get(0)->stringValue());
     EXPECT_TRUE(is_default);
     EXPECT_EQ("b", cd.getValue("value5")->get(1)->stringValue());
+    std::cout << "[XX] full: " << cd.getFullConfig()->str() << std::endl;
+    std::cout << "[XX] 1" << std::endl;
+    std::cout << "[XX] value5: " << cd.getValue(is_default, "value5")->str() << std::endl;
     EXPECT_EQ("b", cd.getValue(is_default, "value5")->get(1)->stringValue());
+    std::cout << "[XX] 2" << std::endl;
+    std::cout << "[XX] value5/:" << cd.getValue(is_default, "value5/")->str() << std::endl;
     EXPECT_EQ("b", cd.getValue(is_default, "value5/")->get(1)->stringValue());
+    std::cout << "[XX] 3" << std::endl;
     EXPECT_TRUE(is_default);
+    std::cout << "[XX] 4" << std::endl;
     EXPECT_EQ("{  }", cd.getValue("value6")->str());
     EXPECT_EQ("{  }", cd.getValue(is_default, "value6")->str());
     EXPECT_EQ("{  }", cd.getValue(is_default, "value6/")->str());