
CatalystX::Usul::Schema - Support for database schemas

0.7.$Revision: 1181 $

package CatalystX::Usul::Model::Schema;
use parent qw(Catalyst::Model::DBIC::Schema
CatalystX::Usul::Model
CatalystX::Usul::Schema);
package YourApp::Model::YourModel;
use parent qw(CatalystX::Usul::Model::Schema);
__PACKAGE__->config( database => q(library),
schema_class => q(YourApp::Schema::YourSchema) );
sub COMPONENT {
my ($class, $app, $config) = @_;
$config->{database } ||= $class->config->{database};
$config->{connect_info} ||=
$class->get_connect_info( $app, $config->{database} );
return $class->next::method( $app, $config );
}

Provides utility methods to classes inheriting from DBIx::Class::Schema
The encryption/decryption methods only obscure the database password from casual viewing, they do not in any way secure it

The XML data looks like this:
<credentials>
<name>database_we_want_to_connect_to</name>
<driver>mysql</driver>
<host>localhost</host>
<password>encrypt=0QqX325DLs18I8T/wU4/ZQQ=</password>
<port>3306</port>
<print_error>0</print_error>
<raise_error>1</raise_error>
<user>root</user>
</credentials>

Called from the constructor of YourApp::Schema this method initialiases the attributes used by the other methods
Creates a database. Understands how to do this for different RDBMSs, e.g. MySQL and PostgreSQL
Dump the database schema definition
Creates a database then deploys and populates the schema
my $plain = $self->decrypt( $seed, $encoded );
Decodes and decrypts the $encoded argument and returns the plain text result. See the "encrypt" method
Create database tables and populate them with initial data. Called as part of the application install
Drops the database that is selected by the call to "get_connect_info"
my $db_info_arr = $self->get_connect_info( $config, $database );
Returns an array ref containing the information needed to make a connection to a database; DSN, user id, password, and options hash ref. The data is read from the XML file in the config ctrldir. Multiple sets of data can be stored in the same file, keyed by the $database argument. The password is decrypted if required. The password decrpytion can be seeded from a text file in the ctrldir
my $encrypted = $self->encrypt( $seed, $plain );
Encrypts the plain text passed in the $plain argument and returns it Base64 encoded. Crypt::Twofish_PP is used to do the encryption. The $seed argument is passed to the "_keygen" method

$self->_edit_credentials( $config );
Writes the database login information stored in the $config to the application config file in the var/etc directory. Called from "create_schema"
$encrypted_value = $self->_encrypt_for_conf( $config, $plain )
Returns the encrypted value of the plain value prefixed appropriately for storage in a config file. Called from "_edit_credentials"
Generates the key used by the "encrypt" and "decrypt" methods. Calls "_inflate" to create the salt. Note that the salt is eval'd in string context

Lifted from Acme::Bleach this recovers the default salt for the key generator

None


There are no known incompatibilities in this module

There are no known bugs in this module. Please report problems to the address below. Patches are welcome

Peter Flanigan, <Support at RoxSoft.co.uk>

Copyright (c) 2011 Peter Flanigan. All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic
This program is distributed in the hope that it will be useful, but WITHOUT WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE