[Gd-chatter] r10895 - trunk/libraries/koala/sources/koala

hannes at gwydiondylan.org hannes at gwydiondylan.org
Mon Sep 4 23:29:08 CEST 2006


Author: hannes
Date: Mon Sep  4 23:29:06 2006
New Revision: 10895

Modified:
   trunk/libraries/koala/sources/koala/server.dylan
   trunk/libraries/koala/sources/koala/utils.dylan
Log:
Job: koala
*remove debug output
*better error handling
 (somehow, using format-arguments didn't work as expected
  (only printing first character), but using format-string works :/)

Modified: trunk/libraries/koala/sources/koala/server.dylan
==============================================================================
--- trunk/libraries/koala/sources/koala/server.dylan	(original)
+++ trunk/libraries/koala/sources/koala/server.dylan	Mon Sep  4 23:29:06 2006
@@ -836,7 +836,7 @@
 end method register-url;
 
 define method register-url-now
-    (url :: <string>, target :: <function>, #key replace?, prefix? = #())
+    (url :: <string>, target :: <function>, #key replace?, prefix?)
   let server :: <server> = *server*;
   let (bpos, epos) = trim-whitespace(url, 0, size(url));
   if (bpos = epos)
@@ -844,9 +844,7 @@
                format-string: "You cannot register an empty URL: %=",
                format-arguments: list(substring(url, bpos, epos))));
   else
-    //format(*standard-output*, "Trying to register url %s now\n", url);
-    let path = split(url, separator: "/");
-    add-object(server.url-map, path, pair(target, prefix?), replace?: replace?);
+    add-object(server.url-map, url, pair(target, prefix?), replace?: replace?);
   end;
   log-info("URL %s registered", url);
 end method register-url-now;

Modified: trunk/libraries/koala/sources/koala/utils.dylan
==============================================================================
--- trunk/libraries/koala/sources/koala/utils.dylan	(original)
+++ trunk/libraries/koala/sources/koala/utils.dylan	Mon Sep  4 23:29:06 2006
@@ -203,29 +203,30 @@
 end;
 
 define method add-object
-    (trie :: <string-trie>, path :: <sequence>, object :: <object>,
+    (trie :: <string-trie>, path :: <string>, object :: <object>,
      #key replace?)
-  //format(*standard-output*, "trying to register %d %=\n", path.size, path);
-  if (path.size = 0)
-    if (trie.trie-object = #f | replace?)
-      //format(*standard-output*, "Successfully added\n");
-      trie.trie-object := object;
-    else
-      signal(make(<trie-error>,
-                  format-string: "Trie already contains an object for the given path."))
-    end;
-  else
-    let first-path = path[0];
-    let rest-path = copy-sequence(path, start: 1);
-    let children = trie-children(trie);
-    let child = element(children, first-path, default: #f);
-    unless (child)
-      let node = make(<string-trie>, object: #f);
-      children[first-path] := node;
-      child := node;
-    end;
-    add-object(child, rest-path, object, replace?: replace?)
-  end;
+  local method real-add (trie :: <string-trie>, rest-path :: <sequence>)
+          if (rest-path.size = 0)
+            if (trie.trie-object = #f | replace?)
+              trie.trie-object := object;
+            else
+              signal(make(<trie-error>,
+                          format-string: format-to-string("Trie already contains an object for the given path (%=).", path)))
+            end;
+          else
+            let first-path = rest-path[0];
+            let other-path = copy-sequence(rest-path, start: 1);
+            let children = trie-children(trie);
+            let child = element(children, first-path, default: #f);
+            unless (child)
+              let node = make(<string-trie>, object: #f);
+              children[first-path] := node;
+              child := node;
+            end;
+            real-add(child, other-path)
+          end;
+        end;
+  real-add(trie, split(path, separator: "/"))
 end method add-object;
 
 // Find the object with the longest path, if any.  2nd return value is
@@ -250,9 +251,6 @@
             end
           end
         end method fob;
-  //let (res1, res2) = fob(trie, as(<list>, path), trie.trie-object, #f);
-  //format(*standard-output*, "res1 %= res2 %=\n", res1, res2);
-  //values(res1, res2);
   fob(trie, as(<list>, path), trie.trie-object, #f);
 end method find-object;
 



More information about the chatter mailing list