Author: hannes
Date: Thu Dec 22 01:04:52 2005
New Revision: 10423
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/network.dylan
trunk/libraries/koala/sources/examples/buddha/subnet.dylan
trunk/libraries/koala/sources/examples/buddha/web-macro.dylan
trunk/libraries/koala/sources/examples/buddha/zone.dylan
Log:
Bug: 7257
more fixes
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 Thu Dec 22
01:04:52 2005
@@ -24,13 +24,6 @@
ns-name: "auth-int.congress.ccc.de"),
make(<nameserver>,
ns-name: "auth-ext.congress.ccc.de"));
-define variable *hostmaster* = "hostmaster.congress.ccc.de";
-define variable *refresh* = 180;
-define variable *retry* = 300;
-define variable *expire* = 600;
-define variable *time-to-live* = 1800;
-define variable *minimum* = 300;
-
define sideways method process-config-element
(node :: <xml-element>, name == #"buddha")
@@ -149,8 +142,16 @@
define page changes end;
define page adduser end;
define page logout end;
-define page dhcp end;
-define page tinydns end;
+
+define responder dhcp-responder ("/dhcp")
+ (request, response)
+ respond-to-get(#"dhcp", request, response);
+end;
+
+define responder tinydns-responder ("/tinydns")
+ (request, response)
+ respond-to-get(#"tinydns", request, response);
+end;
define macro with-buddha-template
{ with-buddha-template(?stream:variable, ?title:expression)
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 Thu Dec
22 01:04:52 2005
@@ -96,26 +96,15 @@
//here we should have at least a seperation between integer,
//strings and lists... or should we implement all lists with
//has-many?
- let value = get-query-value(slot.slot-name);
+ let value = default(slot);
+ if (fill-from-request)
+ value := get-query-value(slot.slot-name);
+ end;
if (slot.slot-type = <boolean>)
- if (fill-from-request & value)
- collect(with-xml() input(type => "checkbox",
- name => slot.slot-name,
- value => slot.slot-name,
- checked => "checked")
- end);
- else
- collect(with-xml() input(type => "checkbox",
- name => slot.slot-name,
- value => slot.slot-name)
- end);
- end;
+ collect(edit-slot(value, slot.slot-name));
else
- if (fill-from-request & value)
- collect(with-xml() input(type => "text",
- name => slot.slot-name,
- value => value)
- end);
+ if (value)
+ collect(edit-slot(value, slot.slot-name));
else
collect(with-xml() input(type => "text",
name => slot.slot-name)
@@ -249,7 +238,7 @@
= method(e :: <buddha-form-warning>, next-handler :: <function>)
errors := add!(errors, e)
end;
- block(return)
+ //block(return)
//add, save, remove... we may not need this here...
unless (object)
signal(make(<buddha-form-error>,
@@ -263,14 +252,14 @@
error: concatenate("Unknown action: ",
as(<string>, action))));
end select;
- exception (e :: <buddha-form-error>)
+ /* exception (e :: <buddha-form-error>)
errors := add!(errors, e);
return();
exception (e :: <error>)
errors := add!(errors, make(<buddha-form-error>,
error: format-to-string("%=", e)));
return();
- end;
+ end; */
let referer = if (get-query-value("refer-to"))
as(<symbol>, get-query-value("refer-to"));
else
@@ -294,6 +283,13 @@
for (slot in data-slots(object-type))
let value = parse(slot.slot-name, slot.slot-type);
//then set slots of object
+ unless ((slot.slot-type = <boolean>) | value)
+ value := slot.default-function(object);
+ unless (value)
+ signal(make(<buddha-form-error>,
+ error-string: concatenate("Please specify ",
slot.slot-name, " correctly!")));
+ end unless;
+ end;
slot.slot-setter-method(value, object);
end;
for (slot in reference-slots(object-type))
@@ -329,12 +325,18 @@
else
#f;
end;
- elseif (type = <string>)
- value;
- elseif (type = <integer>)
- string-to-integer(value)
else
- as(type, value);
+ if (value & (value ~= ""))
+ if (type = <string>)
+ value;
+ elseif (type = <integer>)
+ string-to-integer(value)
+ else
+ as(type, value);
+ end;
+ else
+ #f;
+ end;
end;
end;
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 Thu Dec 22
01:04:52 2005
@@ -33,7 +33,9 @@
slot-type,
slot-getter-method,
slot-setter-method,
- slot-global-list;
+ slot-global-list,
+ default,
+ default-function;
export list-reference-slots,
reference-slots,
Modified: trunk/libraries/koala/sources/examples/buddha/network.dylan
==============================================================================
--- trunk/libraries/koala/sources/examples/buddha/network.dylan (original)
+++ trunk/libraries/koala/sources/examples/buddha/network.dylan Thu Dec 22
01:04:52 2005
@@ -3,22 +3,13 @@
define web-class <network> (<reference-object>)
data cidr :: <cidr>;
- data dhcp? :: <boolean>;
- data dhcp-default-lease-time :: <integer>;
- data dhcp-max-lease-time :: <integer>;
+ data dhcp? :: <boolean> = #t;
+ data dhcp-default-lease-time :: <integer> = 600;
+ data dhcp-max-lease-time :: <integer> = 7200;
data reverse-dns? :: <boolean>;
has-many dhcp-option :: <string>;
end;
-define method initialize (net :: <network>,
- #rest rest, #key, #all-keys)
- next-method();
- net.reverse-dns? := #f;
- net.dhcp? := #t;
- net.dhcp-default-lease-time := 600;
- net.dhcp-max-lease-time := 7200;
-end;
-
define method \< (a :: <network>, b :: <network>)
=> (res :: <boolean>)
a.cidr < b.cidr;
@@ -62,16 +53,17 @@
=> ();
if (print-network.dhcp?)
if (print-network.dhcp-default-lease-time)
- format(stream, "\tdefault-lease-time %d;\n",
+ format(stream, "default-lease-time %d;\n",
print-network.dhcp-default-lease-time);
end if;
if (print-network.dhcp-max-lease-time)
- format(stream, "\tmax-lease-time %d;\n",
+ format(stream, "max-lease-time %d;\n",
print-network.dhcp-max-lease-time);
end if;
do(method(x)
- format(stream, "\t%s;\n", x);
+ format(stream, "%s;\n", x);
end, print-network.dhcp-options);
+ format(stream, "\n");
do(method(x)
print-isc-dhcpd-file(x, stream);
end, choose(method(x)
Modified: trunk/libraries/koala/sources/examples/buddha/subnet.dylan
==============================================================================
--- trunk/libraries/koala/sources/examples/buddha/subnet.dylan (original)
+++ trunk/libraries/koala/sources/examples/buddha/subnet.dylan Thu Dec 22
01:04:52 2005
@@ -12,15 +12,9 @@
define web-class <subnet> (<network>)
has-a vlan;
has-a network;
- data dhcp-start :: <ip-address>;
- data dhcp-end :: <ip-address>;
- data dhcp-router :: <ip-address>;
-end;
-
-define method fixup (subnet :: <subnet>)
- subnet.dhcp-start := base-network-address(subnet.cidr) + 2;
- subnet.dhcp-end := broadcast-address(subnet.cidr) - 1;
- subnet.dhcp-router := base-network-address(subnet.cidr) + 1;
+ data dhcp-start :: <ip-address>, base-network-address(object.cidr) + 2;
+ data dhcp-end :: <ip-address>, broadcast-address(object.cidr) - 1;
+ data dhcp-router :: <ip-address>, base-network-address(object.cidr) + 1;
end;
define method print-object (subnet :: <subnet>, stream :: <stream>)
Modified: trunk/libraries/koala/sources/examples/buddha/web-macro.dylan
==============================================================================
--- trunk/libraries/koala/sources/examples/buddha/web-macro.dylan
(original)
+++ trunk/libraries/koala/sources/examples/buddha/web-macro.dylan Thu Dec
22 01:04:52 2005
@@ -7,6 +7,9 @@
constant slot slot-getter-method :: <function>, init-keyword: getter:;
constant slot slot-setter-method :: <function>, init-keyword: setter:;
constant slot slot-global-list :: <object>, init-keyword: global-list:;
+ constant slot default :: <object> = #f, init-keyword: default:;
+ constant slot default-function :: <function> = method(x :: <object>) #f end,
+ init-keyword: default-function:;
end;
define generic list-reference-slots
@@ -78,12 +81,26 @@
slots:
{ } => { }
- { data ?slot-name:name \:: ?slot-type:*; ... }
+ { data ?slot-name:name \:: ?slot-type:name; ... }
=> { make(<slot>,
name: ?"slot-name",
type: ?slot-type,
getter: ?slot-name,
setter: ?slot-name ## "-setter"), ... }
+ { data ?slot-name:name \:: ?slot-type:name, ?default-function:expression ;
... }
+ => { make(<slot>,
+ name: ?"slot-name",
+ type: ?slot-type,
+ getter: ?slot-name,
+ setter: ?slot-name ## "-setter",
+ default-function: method (?=object :: <object>)
?default-function end), ... }
+ { data ?slot-name:name \:: ?slot-type:name = ?default:expression; ... }
+ => { make(<slot>,
+ name: ?"slot-name",
+ type: ?slot-type,
+ getter: ?slot-name,
+ setter: ?slot-name ## "-setter",
+ default: ?default), ... }
{ ?other:*; ... }
=> { ... }
end;
Modified: trunk/libraries/koala/sources/examples/buddha/zone.dylan
==============================================================================
--- trunk/libraries/koala/sources/examples/buddha/zone.dylan (original)
+++ trunk/libraries/koala/sources/examples/buddha/zone.dylan Thu Dec 22
01:04:52 2005
@@ -49,13 +49,13 @@
data zone-name :: <string>;
data reverse? :: <boolean>;
has-many cname :: <cname>;
- data hostmaster :: <string>;
- data serial :: <integer>;
- data refresh :: <integer>;
- data retry :: <integer>;
- data expire :: <integer>;
- data time-to-live :: <integer>;
- data minimum :: <integer>;
+ data hostmaster :: <string> = "hostmaster.congress.ccc.de";
+ data serial :: <integer> = 0;
+ data refresh :: <integer> = 180;
+ data retry :: <integer> = 300;
+ data expire :: <integer> = 600;
+ data time-to-live :: <integer> = 1800;
+ data minimum :: <integer> = 300;
has-many nameserver :: <nameserver>;
has-many mail-exchange :: <mail-exchange>;
//has-many text :: <string>;
@@ -63,14 +63,6 @@
define method initialize (zone :: <zone>,
#rest rest, #key, #all-keys)
- next-method();
- zone.hostmaster := *hostmaster*;
- zone.serial := 0;
- zone.refresh := *refresh*;
- zone.retry := *retry*;
- zone.expire := *expire*;
- zone.time-to-live := *time-to-live*;
- zone.minimum := *minimum*;
for (ele in *nameserver*)
zone.nameservers := add!(zone.nameservers, ele);
end;
@@ -149,8 +141,9 @@
if (print-zone.reverse?)
//PTR
do(method(x)
- format(stream, "^%s:%s\n",
+ format(stream, "^%s.%s:%s\n",
x.host-name,
+ x.zone.zone-name,
as(<string>, x.ipv4-address));
end, choose(method(x)
ip-in-net?(parse-cidr(print-zone.zone-name),
@@ -158,14 +151,15 @@
end, *config*.hosts));
else
//MX
- //do(method(x)
- // format(stream, "@%s::%s:%d\n",
- // print-zone.zone-name, tail(x), head(x));
- // end, print-zone.mail-exchanges);
+ do(method(x)
+ format(stream, "@%s::%s.%s:%d\n",
+ print-zone.zone-name, mx-name(x), print-zone.zone-name,
priority(x));
+ end, print-zone.mail-exchanges);
//A
do(method(x)
- format(stream, "+%s:%s\n",
+ format(stream, "+%s.%s:%s\n",
x.host-name,
+ x.zone.zone-name,
as(<string>, x.ipv4-address));
end, choose(method(x)
x.zone = print-zone
--
Gd-chatter mailing list
Gd-chatter@xxxxxxxxxxxxxxxx
https://gauss.gwydiondylan.org/mailman/listinfo/gd-chatter
|