http://qs1969.pair.com?node_id=87171

rob_au has asked for the wisdom of the Perl Monks concerning the following question:

This node has been sparked following my question from yesterday (Metadata and DBI Abstraction) into parsing DBI table metadata in the attempt to build an abstraction layer for some CGI scripts I am building for a medium-to-large web site.
 
First of all, I must express thanks to the many monks who /msg-ed me with suggestions and links for my problem - One of which (links, not monks) led me to the Tangram module which allows the creation of orthogonal object abstraction and persistence through UML schemas. While this may not be the final road that I go down for the implementation of my DBI abstraction, this module (I feel) offers some very powerful methods. My problem however, is how to get it all working - For example, following the documentation in the Tangram PODs and on the Tangram Home page, I started experimenting with schema to this end:
 
#!/usr/bin/perl use strict; use Tangram; my ($schema) = Tangram::Schema->new( 'classes' => { 'item' => { 'table' => 'test', 'abstract' => 1, 'fields' => { 'string' => [ qw( category description_short description_long description_table image_1 image_2 supplier_id barcode_id ) ], 'int' => [ qw( manufacturer supplier ) ] } } } ); $schema->deploy();

 
But, despite this following closely to examples from these sources, I am presented with:
 
rob@kathmandu:/development$ ./test.perl Can't locate object method "deploy" via package "Tangram::Schema" (per +haps you forgot to load "Tangram::Schema"?) at ./test.perl line 31.

 
Surely this is something simple which I have overlooked or forgotten, but I have done a little digging (more mundane and rudimentary attempts which I won't bore my fellow monks with) with little success. Prehaps, some of the well know proponents of DBIx::Recordset and Tangram could provide me with further enlightenment?
 
Thanks in advance,
 

 
Ooohhh, Rob no beer function well without!

Replies are listed 'Best First'.
Re: Foray into Tangram and Schemas
by mugwumpjism (Hermit) on Jun 09, 2001 at 17:13 UTC

    One thing I've noticed about Tangram is its shockingly inaccurate documentation and poor error messages when you pass an unexpected object type to a function. But when you do call it with the correct syntax it seems to work well :).

    Once you have a schema, you need to deploy it with a back end. So if you're deploying to a generic relational database:

    #!/usr/bin/perl use strict; use Tangram; use Tangram::Relational; my ($schema) = Tangram::Schema->new( 'classes' => { 'item' => { 'table' => 'test', 'abstract' => 1, 'fields' => { 'string' => [ qw( category description_short description_long description_table image_1 image_2 supplier_id barcode_id ) ], 'int' => [ qw( manufacturer supplier ) ] } } } ); Tangram::Relational->deploy($schema);

    s/Relational/mysql/ if you're using MySQL.