|
CGI::Bus::tm - database Transaction page Manager to view and edit data |
CGI::Bus::tm - database Transaction page Manager to view and edit data
use CGI::Bus; $s =CGI::Bus->new(); $s->tm->...see 'Transaction Sequence' below
This module is database Transaction page Manager to view and edit data.
There are a common TRANSACTION SEQUENCE and
simplest programming interface using cmd(-command) conditions and
direct database calls along with cnd and qparam calls.
Some common transaction commands for more usable programming interface
are also implemented.
Some slots are only predefined for children and not used within this module. Some slots may be extended in subclasses.
See CGI::Bus::tmsql as an example of details and for more advanced SQL database applications development features.
See CGI::Bus::Base for inherited slots and methods.
Transaction sequence is a series of hooks dependent on
current command cmd and
current generic (or general or global) command cmdg.
cmd(-command) calls are used as conditions.
In simplest programming interface this conditions should be programmed.
In more usable programming interface (SQL generator)
this conditions are hidden inside
eval or cmd(-cmd) call evaluating cmdCCC methods,
but may be hooked with -cmdCCC slots.
A transaction sequence looks like something as:
my $s =CGI::Bus->new();
my $t =$s->tmsql;
my $d =$s->dbi; #
eval { # inside $t->eval(?connect, sub{
if ($t->cmd(-chk)) { # check before insert, update, delete # $t->cmdchk
}
if ($t->cmd(-ins)) { # insert record
$d->execute('insert ...', @{$t->qparam([names])});
}
if ($t->cmd(-upd)) { # update record where cnd
$t->cnd(-upd, field=>flags,...);
$d->execute('update ...' .$t->cnd, @{$p->qparam([names])});
}
if ($t->cmd(-del)) { # delete record where cnd
$t->cnd(-del, field=>flags,...);
$d->execute('delete ...' .$t->cnd);
}
if ($t->cmd(-sel)) { # select record fields to edit
$t->cnd(-sel, field=>flags,...);
$p->qparam($d->selectrow_hashref('...' .$t->cnd));
}
if ($t->cmd(-crt)) { # create new record values # $t->cmdcrt
}
if ($t->cmd(-qry)) { # list query condition # $t->cmdqry
}
if ($t->cmd(-htm)) { # html page begin # $t->cmdhtm
print $t->htmlhid;
print $t->htmlbar;
}
if ($t->cmd(-frm)) { # html record form # $t->cmdfrm
# print html form
}
if ($t->cmd(-lst)) { # list records
$t->cnd(-lst, field=>flags,...);
$d->select...
}
if ($t->cmd(-end)) { # commit, inside $t->eval call
$d->commit
}
};
$t->print($t->htmlres);# result msg, inside $t->eval call
}
cmdchk call
-pxpv prefix.
-pxpv prefix.
cmdcrt call.
cmdqry call
cmdhtm call
cmdfrm call
eval call along with htmlres and rollback.
cmd
cnd calls
cmdCCC call.
Commands are described in TRANSACTION SEQUENCE above.
cmd calls
cmd, available via cmdg.
This is any -cmd command exept form exchanges -
-frm, -ins, -upd commands.
cnd
-form by set
-fltsel, -fltlst, -fltedt takes precedence. RESERVED
-fld, -lbl, -cmt, -flg ('k'ey and 'm'andatory), -col
-crt, -frm, -sav, -ins, -upd, -del
-lists,
'$_' is placeholder. RESERVED
-lbl, -cmt, -fields, -key, -orderby
-lst operation
-banner, -tbarl
htmlbar;
'a'll:
'c'reate/'i'nsert, 'e'dit/'u'pdate, 'd'elete,
's'elect (?), 'v'iew record,
'l'ist, 'q'uery records;
!'c'reate/'i'nsert, !'e'dit/'u'pdate, !'d'elete record,
!'s'elect record button, !'v'iew record mode, !'q'uery condition
-upd and -del operation
-lst operation
-cmdCCC subs{}.
May be used for access control.
-rowlst is to be evaluated for each row in cmdlst to filter rows to display.
-rowedt controls record edit appearance.
-rowupd and -rowdel (and -rowsav in this cases)
are to evaluate when previous values
of fields are fetched to -pxpv parameters.
Partially RESERVED.
-rowsav, but immediatelly before or 'a'fter database (SQL) command
generation and execution.
Actual field values to be used for or 'a'fter database command are
available as CGI params.
-rowsav1 is used for edited record only
(new value fieldnames not prefixed).
-rowsav2 is used for each database command
(new value fieldnames may be prefixed).
-rowsel, but immediatelly 'a'fter database (SQL SELECT) command
generation and execution.
Field values are available as CGI params,
both previous (-pxpv) and pending.
-rowsel1a is used while editing record only
(when previous field values selected).
-rowsel2a is used for each record selection
(previous or current field values selected).
-htm operation
-htm operation
Common methods:
qparampv, qparamsw, qparampx, htmlself,
cmd, cmdg,
htmlbar, htmlhid, htmlres, htmlself,
eval, evaluate
Programming interface:
evaluate, eval, cmd, cnd
Transaction commands implementations:
cmdchk, cmdcrt, cmdqry, cmdhtm, cmdfrm, cmdhlp
-chk subs{}.
Calculate fields values with -frm, -sav,
-ins, -upd, -del subs{}
before insert, update, delete
-crt default values for new record
-cmd command
exept form exchanges like -frm, -ins, -upd.
-form and -lists
descriptions
htmlbar and htmlhid.
-qry default values for query parameters form
-lst transaction.
Field values are given from CGI params.
Field formats may be
empty, quote (``''', '``'), sub, string template with '?' placeholder for value.
htmlres, commit or rollback on errors.
Default procedure is cmd('-cmd').
See also evaluate
eval, but with starting HTTP,
starting and ending HTML page.
Uses '-htpgstart' and '-htpfstart' from parent CGI::Bus
-opflg,
current transaction, -tbarl , -tbarr.
cmd and TRANSACTION SEQUENCE for commands.
Attributes for 'A' HTML tag may be given as an array or hash ref.
-pxcb, -pxsw, -pxpv, -pxqc.
qparam call with -pxpv prefixed param names.
qparam call with prefixed param names.
Empty prefix means non-prefixed names.
qparam call with -pxsw prefixed param names.
New -banner.
New !'c'reate/'i'nsert, !'d'elete, !'e'dit/'u'pdate, !'q'uery -opflg options.
New cmdfe method.
Changed htmlbar considering -vsd option.
New experimantal _tsw_LSO / qloval / qlourl / qlowgh / qlowgl / qloparse
interface to implement options embedded into views.
evaluate executes now some CGI::Bus::upws
'_run' commands as full-text 'SEARCH' or user 'SETUP'.
qlst may determine default view via '_' sign not only at the end of
the view name, but at the end of the view label too.
htmlbar button set behaviour:
'Login' button moved after 'Back' and will be always shown for guests;
'Login' button small picture resized;
'List' button in the record form replaced with 'Query' button
and excluded when record editing;
'Edit' button will not be shown for guests.
cmdfrm 'l'ist, 's'elect, '``'quoted only fields (-flg =~/^['''ls]*$/)
are not considered in form layout now
cmdfrm text area formatting improved with ' ' signs and '<code>' tags as needed.
cmdfrm lost line breacks when displaying text areas with embedded URLs
-logo slot
htmlbar and cmdhlp behaviour for '<' -opflg.
-refresh view and common slots
-htmlts, -htmlte, -width common slots
-rowsav1 and -rowsav2 events inside cmdsql.
- textarea fields displays linebreaks when viewed - 'Select' and 'Edit' command buttons appearance - '!s'elect record button '-opflg' value
- imagebuttons toolbar using -iurl slot; uncomment at the beginning of the source to disable; see issue in the source code
- review & test & debug
- how to move 'qparampv' and 'qparamsw' methods up to the application object?
Andrew V Makarow <makarow at mail.com>
|
CGI::Bus::tm - database Transaction page Manager to view and edit data |