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

NAME

Rubberband - (Even more!) Extensible framework around Maypole

SYNOPSIS

In Foo.pm:

    package Foo;
    use Rubberband (
        search_path => [ "Foo", "Foo::Plugin" ],
        dsn => "dbi:SQLite:foo.db",
        translate_sql_from => "MySQL",
    );
    Foo->config->{uri_base} = "http://localhost/";
    # Other Maypole configuration parameters

From the command line:

    perl -MFoo -e 'Foo->setup_database_tables'

Or when adding a new plugin:

    perl -MFoo -e 'Foo::Plugin::Magic->run_data_sql'

In Foo/Plugin/Magic.pm:

    package Foo::Plugin::Magic;
    Foo::Plugin::Magic->table("magic");
    Foo::Plugin::Magic->columns(...);

    sub conjure :Exported {
        my ($self, $r) = @_;
        $r->{objects} = [ Foo->call_plugins("collate_magic") ];
    }
    __DATA__
    CREATE TABLE magic (
        id integer auto_increment NOT NULL PRIMARY KEY,
        name varchar(255),
        spell text
    );

DESCRIPTION

Maypole as a web application framework is easy to extend "vertically" by adding new Exported methods, but not so easy to extend "horizontally" by adding new "concepts" (that is, classes and tables).

Rubberband, as its name implies, is designed to be stretched in both directions. It uses Module::Pluggable::Ordered to locate the classes which encapsulate the tables, and also to provide a callback functionality to allow extensions to "talk" to each other; it also uses Class::DBI::DATA::Schema to allow extension classes to declare the SQL to set up their tables. Further, it helps to set up your classes by creating a backend Foo::DBI class (given an application called Foo, of course...) which handles the connection information, and from which your plugin modules automatically inherit.

OPTIONS

The interface to the module is through options passed on the use line. The following options are available:

dsn

This is required - it is the DBI data source you will be using.

package

The package to set up. You almost never want to set this to anything other than the default, which is the calling package.

maypole

The Maypole front-end class in use; this defaults to Apache::MVC.

maypole_model

The Maypole back-end class; this defaults to Maypole::Model::CDBI::Plain.

cdbi

The Class::DBI base class; this defaults to Class::DBI::BaseDSN.

search_path

This, and other Module::Pluggable::Ordered options, are passed on to that module.

translate_sql_from

When your DATA section contains the SQL to create your table, and someone uses the module with a different database from yours, they're going to need the SQL translated into the SQL variety spoken by their database. This can be done if you declare what SQL variety your SQL is in, by passing in a translate_sql_from option.

SEE ALSO

Maypole, Module::Pluggable::Ordered, Class::DBI::DATA::Schema.

AUTHOR

Simon Cozens, <simon@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2004 by Simon Cozens

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