The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

List::Filter::Storage::DBI - filter storage via DBI

SYNOPSIS

   # This is a plugin, not intended for direct use.
   # See: List:Filter:Storage

   use List::Filter::Storage::DBI;
   my $lfps_dbi = List::Filter::Storage::DBI->new(
         type       => 'filter',
         connect_to => $connect_to,
         owner      => $owner,
         password   => $password,
   );

DESCRIPTION

This is a general, database-neutral (or so I hope) storage plugin that should allow for reading and writing List::Filter filters from any database with a DBI driver.

Note that in the event that database-specific code is needed, A specific plugin that inherits from this one can be written: the List::Filter system should find it automatically, if it's named in the standard way (ala DBD::*). E.g. a postgresql driver would be

  List::Filter::Storage::DBI::Pg

METHODS

initialization code

new

Takes an optional hashref as an argument, with named fields identical to the names of the object attributes.

With no arguments, the newly created filter will be empty.

init

Initialize object attributes and then lock them down to prevent accidental creation of new ones.

Note: there is no leading underscore on name "init", though it's arguably an "internal" routine (i.e. not likely to be of use to client code).

create_filter_table

Creates the standard storage tables for this object's type.

create_table

Takes a block of sql as an argument, which is expected to contain a CREATE TABLE statement. Tries to run the sql, but does not object if the table already exists already. However, this method "croaks" on any other error.

Note: It tries to create the table, and traps the error if it exists already. This is more portable -- to my knowledge -- than trying to get a listing of existing tables.

init_dbh

Initializes database connection.

main methods

lookup
save

Saves the given filter object to the database.

Refuses to save filters named with a leading underscore.

Returns the filter on success, otherwise undef.

list_filters

Returns a list of all avaliable named filters.

special accessors (access the "extra" namespace)

dbh

Getter for object attribute dbh

When called for the first time, initiates database connection.

set_dbh

Setter for object attribute set_dbh

basic accessors (defined in List::Filter::Storage);

connect_to

Getter for object attribute connect_to

set_connect_to

Setter for object attribute set_connect_to

owner

Getter for object attribute owner

set_owner

Setter for object attribute set_owner

password

Getter for object attribute password

set_password

Setter for object attribute set_password

attributes

Getter for object attribute attributes

set_attributes

Setter for object attribute set_attributes

extra

Getter for object attribute extra

set_extra

Setter for object attribute set_extra

Design Notes

This single table schema isn't an efficient use of an RDMS, but the needs here are relatively simple, and this should be fairly portable.

The primary simplification used here is to serialize the array of terms and store it in a single text field.

Data::Dumper has been used for serialization (in preference to Storable) to improve the readability of the database.

SEE ALSO

List::Filter::Project List:Filter:Storage List::Filter

AUTHOR

Joseph Brenner, <doom@kzsu.stanford.edu>, 18 May 2007

COPYRIGHT AND LICENSE

Copyright (C) 2007 by Joseph Brenner

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.2 or, at your option, any later version of Perl 5 you may have available.

BUGS

None reported... yet.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 194:

You forgot a '=back' before '=head2'