From 1f230acff97f4d0a138ee78a0599d2d6578a5625 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Tue, 14 Nov 2006 16:21:08 +0000 Subject: [PATCH] Add code to generate ID automatically, when missing, from host, port and database, when present. --- web/htdocs/chrome/layout.mc | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/web/htdocs/chrome/layout.mc b/web/htdocs/chrome/layout.mc index 88cc9e1..adaac28 100644 --- a/web/htdocs/chrome/layout.mc +++ b/web/htdocs/chrome/layout.mc @@ -1,9 +1,30 @@ -%# $Id: layout.mc,v 1.15 2006-11-01 10:01:14 mike Exp $ +%# $Id: layout.mc,v 1.16 2006-11-14 16:21:08 mike Exp $ <%args> $debug => undef $title $component +<%perl> +{ + # Make up ID for newly created records. It would be more + # rigorously correct, but insanely inefficient, to submit the + # record to Zebra and then search for it; but since we know the + # formula for IDs anyway, we just build one by hand. + my $id = $r->param("id"); + my $host = $r->param("host"); + my $port = $r->param("port"); + my $dbname = $r->param("dbname"); + #warn "id='$id', host='$host', port='$port', dbname='$dbname'"; + #warn "%ARGS = {\n" . join("", map { "\t'$_' => '" . $ARGS{$_} . ",'\n" } sort keys %ARGS) . "}\n"; + if ((!defined $id || $id eq "") && + defined $host && defined $port && defined $dbname) { + $id = "$host:$port/$dbname"; + $r->param(id => $id); + $ARGS{id} = $id; + #warn "id set to '$id'"; + } +} + <%once> use URI::Escape; use ZOOM::IRSpy::Web; -- 1.7.10.4