From: Chris W. <ch...@cw...> - 2001-02-08 03:30:50
|
I'm happy to announce the release of SPOPS 0.38. What is it? S imple P erl O bject P ersistence with S ecurity Since this *is* a list devoted to object persistence, I'll just quote from the gospels of the README: ---------------------------------------- WHAT IS IT? ==================== SPOPS is a robust and powerful module that allows you to serialize objects. It is unique in that it also allows you to apply security to these objects using a fairly simple but powerful scheme of users and groups. (You can, of course, turn off security if you want.) It's also unique in that for most objects, you will not need to write any code. It's true! A fairly simple configuration file is all you need which you can then feed to SPOPS and have a class for your object ready to go, right out of thin air. The configuration you specify not only lists the properties of the object and possibly some information about where its data should be stored, but can also describe the relationship an object might have with another object (or objects). One great benefit is that you can retrofit SPOPS to existing data. If you don't use any of the metadata layers or security, you can simply describe your data in a configuration file, process the configuration and start making (and processing) objects! If you want to add security to these objects later, it's easy! SHOW ME THE CODE! ==================== Here's a sample session. In it, we have a simple configuration file which names the table in our database and the fields in the table, along with the primary key field. We process the config, then create a new object with our just-created class. (Note that this code is copied directly from the file 'eg/fatbomb_dbi.pl'. See it for more details or to run it yourself.) my $spops = { fatbomb => { class => 'My::ObjectClass', isa => [ qw/ SPOPS::DBI::MySQL SPOPS::DBI / ], field => [ qw/ fatbomb_id calories cost name servings / ], base_table => 'fatbomb', id_field => 'fatbomb_id', skip_undef => [ qw/ servings / ], sql_defaults => [ qw/ servings / ], }, }; SPOPS::Configure::DBI->process_config( { config => $spops, require_isa => 1 } ); My::ObjectClass->class_initialize; my $object = My::ObjectClass->new; $object->{calories} = 1500; $object->{cost} = '$3.50'; $object->{name} = "Super Deluxe Jumbo Big Mac"; my $fb_id = eval { $object->save( { db => $db } ) }; if ( $@ ) { my $ei = SPOPS::Error->get; die "Error found! ($@) Error information: ", Dumper( $ei ), "\n"; } print "Object saved ok!\n", "Object ID: $fb_id\n", "Servings: $object->{servings}\n"; We can strip out the 'skip_undef' and 'sql_defaults' items in the configuration and we'd have the bare minimum configuration for a SPOPS::DBI object. APPLICATION-SPECIFICITY ==================== Up to now, this library has been tied relatively closely to the OpenInteract project (www.openinteract.org, or check out the CPAN module OpenInteract). However, it should be able to stand on its own two feet -- we've used it like this without any problem. But there might be a few assumptions lurking around the code somewhere. If you spot something that looks totally out of place or appears to have no real purpose, let us know! HOW DO I SAY IT? ==================== It's usually pronounced so it rhymes with 'mess mops', although you're free to make up your own. ---------------------------------------- SPOPS is available through CPAN using a Bundle file (Bundle::SPOPS) and has CVS available at SourceForge under the auspices of the OpenInteract project. http://sourceforge.net/projects/openinteract/ If there's enough interest we can create a separate mailing list, but in the meantime if you have questions shoot them over to the openinteract-dev list. Thanks! Chris -- Chris Winters (ch...@cw...) Building enterprise-capable snack solutions since 1988. |