The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Oryx - Meta-Model Driven Object Persistance with Multiple Inheritance

SYNOPSIS

 #===========================================================================
 # connect to storage
 $storage = Oryx->connect(['dbi:Pg:dbname=cms', $usname, $passwd]);
 
 # or specify a schema
 $storage = Oryx->connect(
    ["dbi:Pg:dbname=cms", $usname, $passwd], 'CMS::Schema'
 );
 
 # for DBM::Deep back-end
 Oryx->connect(['dbm:Deep:datapath=/path/to/data'], 'CMS::Schema');

 #===========================================================================
 # deploy the schema
 $storage->deploySchema();              # for all known classes (via `use')
 $storage->deploySchema('CMS::Schema');
 $storage->deployClass('CMS::Page');
 
 # automatically deploy as needed
 use Oryx ( auto_deploy => 1 );           # for all classes
 CMS::Page->auto_deploy(1);             # only for this class
 

DESCRIPTION

Oryx is an Object Persistence framework which supports both object-relational mapping as well as DMB style databases and as such is not coupled to any particular storage back-end. In other words, you should be able to swap out an RDMBS with a DBM style database (and vice versa) without changing your persistent classes at all.

This is achieved with the use a meta model which fits in as closely with Perl's own as possible - and due to Perl's excellent introspection capabilities and enormous flexibility - this is very close indeed. For this reason Hash, Array and Reference association types are implemented with liberal use of `tie'. The use of a meta model, albeit a very transparent one, conceptually supports the de-coupling of storage back-end from persistent classes, and, for the most part, beside a really small amout of meta-data, you would use persistent classes in a way that is virtually indistinguishable from ordinary perl classes.

INTRODUCTION

This documentation applies to classes persisted in DBM::Deep style storage as well except insofar as the implementation details are concerned where tables and columns are mentioned - separate files are used for DBM::Deep based storage instead of tables (see Oryx::DBM for details).

This is still a very early release and only supports DBM::Deep, MySQL SQLite and Postgres back-ends at the moment. Having said this, however, Oryx is already quite usable. It needs to be thrashed a lot more and support for the rest of the popular RDBMS needs to be added. Things will change (for the better, one hopes); if you're interested in helping to precipitate that change... let me know, you'd be most welcome.

OVERVIEW

The documentation is in the process of being divided up between the different components:

Oryx::Class

Contains the details for defining persistent classes and how to use them. Read this first.

Oryx::Association

Describes Associations meta-types in more detail.

Oryx::Attribute

Explains Attribute meta-types.

Oryx::Parent

All about Inheritance in Oryx.

Oryx::Value

A description of our DB friendly primitive types.

Oryx::Manual::Guts

Oryx meta-model and internals for developers.

CONNECTING TO STORAGE

The call to Oryx->connect(...) specifies the dsn and connection credentials to use when connecting where applicable. For DBM::Deep style storage, the connection arguments look like this:

 Oryx->connect(['dbm:Deep:datapath=/path/to/data'], 'CMS::Schema');

For RDBMS (Postgres in this case) it may look like this:

 Oryx->connect(["dbi:Pg:dbname=cms", $usname, $passwd], 'CMS::Schema');

The Schema defaults to 'Oryx::Schema' and is therefore optional, so we could say Oryx->connect([ ... dsn ... ]), and forget about passing in a Schema.

One advantage to using separate Schema classes is that this gives you namespace separation where you need to connect several sets of classes to different storage back ends (especially where these are mixed in such a way where the same classes exist in different stores). Another advantage is that the Schema class may define a prefix method which simply returns a string to prefix table names with, for those of us who only get a single database with our hosting package and need to have some namespace separation.

Here's an example of a Schema class :

 package CMS::Schema;
 use base qw(Oryx::Schema);
 
 sub prefix { 'cms' }
 
 1;

TODO

Add support for bidrectional associations

At the moment all associations are implemented as unidirectional

Add Oryx::Association::Set

Set associations using Set::Object

test test test

Tests are a bit sparse at the moment.

Support for Oracle, etc.

Only MySQL, PostgreSQL SQLite and DBM::Deep are supported currently. It should be fairly trivial to add support for the other RDBMS'

More documentation

BUGS

I'm sure there are some... if I had more tests, I know I'd find 'em

ACKNOWLEDGEMENTS

Special thanks to:

Sam Vilain

For educating me about meta-models, feedback and for hosting the subversion repository.

Andrew Sterling Hanenkamp

For bug reports and patches, and his ongoing help with documentation, tests and good suggestions.

SEE ALSO

Class::DBI, Tangram, Class::Tangram, SQL::Abstract, Class::Data::Inheritable, Data::Types, DBM::Deep, DBI, ImA::DBI

AUTHOR

Copyright (C) 2005 Richard Hundt <richard NO SPAM AT protea-systems.com>

LICENSE

Oryx may be used under the same terms as Perl itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 265:

You forgot a '=back' before '=head1'

You forgot a '=back' before '=head1'