|
From: Chris W. <ch...@cw...> - 2001-10-28 02:51:33
|
Thought this might be interesting for the whole group.
Chris
----- Forwarded message from Chris Winters <ch...@cw...> -----
From: Chris Winters <ch...@cw...>
To: Mike Eggleston <mi...@mi...>
Subject: Re: [Openinteract-help] fruit-0.09
Date: Sat, 27 Oct 2001 22:46:48 -0400
Message-ID: <200...@ge...>
User-Agent: Mutt/1.3.22i
* Mike Eggleston (mi...@mi...) [011027 22:20]:
> Thanks for the help.
> Do you know of any reverse-engineering method to move existing postgres
> tables and data into OI structures so they can be made into
> packages?
Well, you can make them into objects fairly easily by using the
eg/My/DiscoverField.pm example in SPOPS -- this will be integrated
into the next version of OI. (I've named it
'OpenInteract::DiscoverField' in the example configuration below, but
you can of course name it whatever you like.)
This allows you to define an object with basically just the table name
and primary key field:
my $config = {
myobject => {
class => 'OpenInteract::MyObject',
code_class => [],
isa => [ qw/ OpenInteract::SPOPS::DBI SPOPS::DBI::Pg
SPOPS::DBI / ],
rules_from => [ 'OpenInteract::DiscoverField' ],
field_discover => 'yes',
field => [],
id_field => 'object_id',
increment_field => 1,
no_insert => [ 'object_id' ],
no_update => [ 'object_id' ],
base_table => 'mytable',
track => { create => 1, update => 1, remove => 1 },
name => 'name_field',
object_name => 'MyObject',
},
};
Generating something like this automatically would be pretty easy,
although you'd probably generate the alias ('myobject'), class name
('OpenInteract::MyObject'), object name ('MyObject') from the table
name or something. (You'd also need to specify 'name', but that's not
hard.)
Then you can use OpenInteract::CommonHandler to generate a handler for
searching, displaying, editing and removing objects from the
tables. See OpenInteract::CommonHandler for an example -- again, some
of it you should be able to generate but you'd probably want to edit
it by hand afterward as well. (The docs for this have been updated in
CVS, and that version has a few extra features as well...)
You'd also need to generate the templates. Again, you'd probably want
to do an initial generation and then fine tune it afterward. Using the
template widgets would probably make your job easier.
Another example would be the 'classified' package that shipped with OI
1.30 -- it uses the template widgets and OpenInteract::CommonHandler.
Being able to point OI at a table and generate all this stuff, even if
you needed to fine-tune it after generating it, would be pretty
slick.
----- End forwarded message -----
--
Chris Winters (ch...@cw...)
Building enterprise-capable snack solutions since 1988.
|