[Gd-chatter] r11420 - trunk/libraries/network/koala/sources/koala
turbo24prg at gwydiondylan.org
turbo24prg at gwydiondylan.org
Tue Jul 3 13:17:46 CEST 2007
Author: turbo24prg
Date: Tue Jul 3 13:17:42 2007
New Revision: 11420
Modified:
trunk/libraries/network/koala/sources/koala/dsp.dylan
trunk/libraries/network/koala/sources/koala/library-unix.dylan
trunk/libraries/network/koala/sources/koala/library.dylan
trunk/libraries/network/koala/sources/koala/server.dylan
trunk/libraries/network/koala/sources/koala/utils.dylan
Log:
Job: minor
implemented removal of trie-objects and responders
Modified: trunk/libraries/network/koala/sources/koala/dsp.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/koala/dsp.dylan (original)
+++ trunk/libraries/network/koala/sources/koala/dsp.dylan Tue Jul 3 13:17:42 2007
@@ -124,6 +124,14 @@
respond-to-head(page, request, response);
end;
+define method post (page :: <page>)
+ respond-to(#"post", page, current-request(), current-response());
+end;
+
+define method get (page :: <page>)
+ respond-to(#"get", page, current-request(), current-response());
+end;
+
// Applications should call this to register a page for a particular URL.
define function register-page
(url :: <string>, page :: <page>, #key replace?, prefix?)
Modified: trunk/libraries/network/koala/sources/koala/library-unix.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/koala/library-unix.dylan (original)
+++ trunk/libraries/network/koala/sources/koala/library-unix.dylan Tue Jul 3 13:17:42 2007
@@ -73,7 +73,14 @@
quote-html, // Change < to < etc
register-init-function,
run-init-functions,
- <string-trie>, find-object, add-object, <trie-error>,
+
+ <string-trie>,
+ find-object,
+ add-object,
+ remove-object,
+ trie-children,
+ trie-object,
+ <trie-error>,
<expiring-mixin>,
expired?,
@@ -145,6 +152,7 @@
start-server,
stop-server,
register-url,
+ remove-responder,
<request>,
*request*, // Holds the active request, per thread.
current-request, // Returns the active request of the thread.
@@ -388,8 +396,6 @@
respond-to, // Implement this for you page to handle a request
get, post, // convenience
-
-
page-source,
page-source-setter,
Modified: trunk/libraries/network/koala/sources/koala/library.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/koala/library.dylan (original)
+++ trunk/libraries/network/koala/sources/koala/library.dylan Tue Jul 3 13:17:42 2007
@@ -73,7 +73,14 @@
quote-html, // Change < to < etc
register-init-function,
run-init-functions,
- <string-trie>, find-object, add-object, <trie-error>,
+
+ <string-trie>,
+ find-object,
+ add-object,
+ remove-object,
+ trie-children,
+ trie-object,
+ <trie-error>,
<expiring-mixin>,
expired?,
@@ -145,6 +152,7 @@
start-server,
stop-server,
register-url,
+ remove-responder,
<request>,
*request*, // Holds the active request, per thread.
current-request, // Returns the active request of the thread.
@@ -386,6 +394,7 @@
respond-to-post, // Implement this for your page to handle POST requests
respond-to-head, // Implement this for your page to handle HEAD requests
respond-to,
+ get, post, // convenience
page-source,
page-source-setter,
Modified: trunk/libraries/network/koala/sources/koala/server.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/koala/server.dylan (original)
+++ trunk/libraries/network/koala/sources/koala/server.dylan Tue Jul 3 13:17:42 2007
@@ -923,6 +923,12 @@
end
end find-responder;
+define open generic remove-responder (object :: <object>);
+
+define method remove-responder (url :: <string>)
+ remove-object(*server*.url-map, url)
+end;
+
// Register a function that will attempt to register a responder for a URL
// if the URL matches the file extension. The function should normally call
// register-url (or register-page for DSPs) and should return a responder.
Modified: trunk/libraries/network/koala/sources/koala/utils.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/koala/utils.dylan (original)
+++ trunk/libraries/network/koala/sources/koala/utils.dylan Tue Jul 3 13:17:42 2007
@@ -219,6 +219,27 @@
real-add(trie, split(path, separator: "/"))
end method add-object;
+define method remove-object (trie :: <string-trie>, path :: <string>)
+ let path = split(path, separator: "/");
+ let nodes = #[];
+ let node = reduce(method (a, b)
+ nodes := add!(nodes, a);
+ a.trie-children[b]
+ end, trie, path);
+ let object = node.trie-object;
+ node.trie-object := #f;
+ block (stop)
+ for (node in reverse(nodes), child in reverse(path))
+ if (size(node.trie-children[child].trie-children) = 0 & ~node.trie-object)
+ remove-key!(node.trie-children, child);
+ else
+ stop()
+ end if;
+ end for;
+ end;
+ object;
+end;
+
// Find the object with the longest path, if any. 2nd return value is
// the part of the path that came after where the object matched.
//
More information about the chatter
mailing list