At 12:16 PM 5/17/00 -0600, Bruce W. Hoylman wrote:
>Ciao!
>
>I am searching for the makings of a framework built around or within
>mod_perl/Apache::DBI that supports the consistent update of a record
>within a database. Primarily I am wanting to ensure read/write
>integrity between database accesses by the web client, meaning I wish to
>ensure the record about to be updated meets the following criteria:
>
> 1) It exists. If it does not, perform an insert instead
> 2) If it exists, check that it is unchanged from the time the web
> client first retrieved it for update. If it has changed, throw
> an exception. I do not want a "last update wins" situation.
This first criteria seems a tad odd to me. What business scenario is there
for this?
To me, when a user issues an update they expect that the record exists. In
a way, if the record does NOT exist, then you are really going against your
rule #2. That is, if they issue an update and the record no longer exists,
then that is also a change to the record that someone did (a deletion) and
you are effectively overriding someone elses deletion.
>This is being done in an mod_perl/embperl/Apache::DBI environment.
>
>Suggestions or pointers to additional information would be greatly
>appreciated.
>
>Peace.
An application which implements #2 and is accelerated when used with
mod_perl (Apache::Registry) and Apache::DBI is our latest version of WebDB.
You may download a copy at http://www.extropia.com/ and click on download
button at the top upper right)...
If you want to read about it, the docs are located at
http://www.extropia.com/docs/webdb/. Actually it was all generated using
Stas Bekman's mod_perl guide generator (except using my pods instead of
Stas's mod_perl guide pods)
The WebDB will do #2 for you and, in fact, allows configuring the strategy
of updates... eg you can choose to check all fields for changes, a subset
of fields for changes, or just "key fields" for changes... similar to the
PowerBuilder DataWindow model of handling client-server updates. This is
done through the use of Extropia::DataSource which is a library that
abstracts this stuff away.
By default, WebDB is distributed to be configured to use
Extropia::DataSource::File, but you just need to take out the file specific
stuff from the config and then replace -TYPE => 'File' with -TYPE => "DBI"
and add -DSNAME => 'dbi:yourdatabase etc..." and you are pretty much off
and running.
So the caveat is that the app is configured by default to work on any
CGI/Perl environment. But it has been architected to take advantage of
mod_perl's benefits (eg Apache::DBI) by just changing config parameters in
the setup file.
Since all the new extropia apps follow this common architecture, we have
documented the mod_perl specific tuning issues in the Advanced Chapter of
the Extropia Apps Guide (a supplement to the WebDB Guide) located at
http://www.extropia.com/docs/extropia_app/
If you don't like WebDB itself and need to write your own logic, then you
may want to just use Extropia::DataSource by itself (which implements the
logic you want as an object but no CGI workflow exists around it). The
documentation and code for that set is located at
http://www.extropia.com/ExtropiaObjects/
Hope this helps,
Gunther
__________________________________________________
Gunther Birznieks ([EMAIL PROTECTED])
Extropia - The Web Technology Company
http://www.extropia.com/