Author: hannes
Date: Mon Oct 17 02:50:59 2005
New Revision: 10270
Modified:
trunk/libraries/koala/sources/examples/buddha/buddha.dylan
trunk/libraries/koala/sources/examples/buddha/class-editor.dylan
trunk/libraries/koala/sources/examples/buddha/library.dylan
trunk/libraries/koala/sources/examples/buddha/object-table.dylan
Log:
Bug: 7257
hide $obj-table from other modules
use get-object instead
Modified: trunk/libraries/koala/sources/examples/buddha/buddha.dylan
==============================================================================
--- trunk/libraries/koala/sources/examples/buddha/buddha.dylan (original)
+++ trunk/libraries/koala/sources/examples/buddha/buddha.dylan Mon Oct 17
02:50:59 2005
@@ -103,7 +103,10 @@
unless (obj-string)
obj-string := "";
end;
- let obj = element($obj-table, obj-string, default: *config*);
+ let obj = get-object(obj-string);
+ unless (obj)
+ obj := *config*;
+ end;
with-buddha-template(out, "Edit")
show-errors(errors);
with-xml()
@@ -125,7 +128,10 @@
unless (obj-string)
obj-string := "";
end;
- let obj = element($obj-table, obj-string, default: *config*);
+ let obj = get-object(obj-string);
+ unless (obj)
+ obj := *config*;
+ end;
with-buddha-template(out, "Browse")
with-xml()
div(id => "content") {
@@ -276,19 +282,13 @@
let out = output-stream(response);
let obj-list = get-query-value("obj-id");
let parent-obj = get-query-value("obj-parent");
- if (~obj-list | obj-list = "")
+ obj-list := get-object(obj-list);
+ unless (obj-list)
obj-list := *config*.subnets;
- else
- obj-list := element($obj-table,
- obj-list,
- default: *config*.subnets);
end;
- if (~parent-obj | parent-obj = "")
+ parent-obj := get-object(parent-obj);
+ unless (parent-obj)
parent-obj := *config*;
- else
- parent-obj := element($obj-table,
- parent-obj,
- default: *config*);
end;
with-buddha-template(out, concatenate("Subnets in ",
as(<string>, parent-obj)))
Modified: trunk/libraries/koala/sources/examples/buddha/class-editor.dylan
==============================================================================
--- trunk/libraries/koala/sources/examples/buddha/class-editor.dylan
(original)
+++ trunk/libraries/koala/sources/examples/buddha/class-editor.dylan Mon Oct
17 02:50:59 2005
@@ -228,7 +228,7 @@
end;
block(return)
//add, save, remove... we may not need this here...
- let object = element($obj-table, object-string, default: #f);
+ let object = get-object(object-string);
unless (object)
signal(make(<buddha-form-error>,
error: concatenate("Unknown object: ", object-string)));
@@ -250,9 +250,7 @@
define method add-object (parent-object :: <object>, request :: <request>)
//look what type of object needs to be generated
- let object = element($obj-table,
- get-query-value("obj"),
- default: #f);
+ let object = get-object(get-query-value("obj"));
//if <string>, that's easy
if (instance?(object, <string>))
let value = get-query-value("string");
@@ -266,9 +264,7 @@
slot.slot-setter-method(value, object);
end;
for (slot in reference-slots(object))
- let value = element($obj-table,
- get-query-value(slot.slot-name),
- default: #f);
+ let value = get-object(get-query-value(slot.slot-name));
slot.slot-setter-method(value, object);
add-to-list(value, object);
end;
@@ -279,9 +275,7 @@
define method remove-object (parent-object :: <object>, request :: <request>)
//read object value, get it from $obj-table
- let object = element($obj-table,
- get-query-value("remove-this"),
- default: #f);
+ let object = get-object(get-query-value("remove-this"));
//sanity type-check
//remove from parent list and other has-a references
for (slot in reference-slots(object))
@@ -323,9 +317,7 @@
//now something completely different
for (slot in reference-slots(object))
//get new value via reference
- let value = element($obj-table,
- get-query-value(slot.slot-name),
- default: #f);
+ let value = get-object(get-query-value(slot.slot-name));
//error check it!
//slot-setter!
let current-object = slot.slot-getter-method(object);
Modified: trunk/libraries/koala/sources/examples/buddha/library.dylan
==============================================================================
--- trunk/libraries/koala/sources/examples/buddha/library.dylan (original)
+++ trunk/libraries/koala/sources/examples/buddha/library.dylan Mon Oct 17
02:50:59 2005
@@ -48,7 +48,7 @@
<string-table> };
export get-reference,
- $obj-table;
+ get-object;
end;
define module class-browser
Modified: trunk/libraries/koala/sources/examples/buddha/object-table.dylan
==============================================================================
--- trunk/libraries/koala/sources/examples/buddha/object-table.dylan
(original)
+++ trunk/libraries/koala/sources/examples/buddha/object-table.dylan Mon Oct
17 02:50:59 2005
@@ -9,3 +9,12 @@
$obj-table[address] := object;
address;
end;
+
+define method get-object (reference :: singleton(#f))
+ => (res :: false-or(<object>))
+ #f;
+end;
+
+define method get-object (reference :: <string>) => (res :: false-or(<object>))
+ element($obj-table, reference, default: #f);
+end;
\ No newline at end of file
--
Gd-chatter mailing list
Gd-chatter@xxxxxxxxxxxxxxxx
https://gauss.gwydiondylan.org/mailman/listinfo/gd-chatter
|