Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: db -> HTML::Template abstraction abstraction -- level up!

by Sifmole (Chaplain)
on Jun 16, 2004 at 17:59 UTC ( #367342=note: print w/replies, xml ) Need Help??

in reply to abstraction -- level up!

I use a set of libraries that I created a while back that does very much this kind of thing.

There is a base class which supports all the basic get / set functions, a meta-SQL language ( I know that this is not liked by many ), and one very important function "unroll()".

I have a class for each table, or join of tables, in the db. Each of these classes inherits from the base class, and thus "can" unroll itself. Unroll knows how to crawl the attributes and arrays within the class and produce an HTML::Template friendly representation of the data within the instance.

Within the driver code, which is usually procedural, I build an array of the data that is supposed to be made available to the template processor. I pass this array and the template name to a Display function. It unrolls the objects in the array, then processes the template using the new HTML::Template friendly struct.

The naming of the template values is standardized so that you know how to call them; for instance a class FOO with an attribute "bar" would be in the hash as "" variable.

I have lately been wondering whether Class::DBI supports this kind of transformation because I would be interested in replacing my home-grown code, which attempts the same thing as Class::DBI, with Class::DBI.

Does anyone know?

  • Comment on Re: db -> HTML::Template abstraction abstraction -- level up!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://367342]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2018-05-23 11:53 GMT
Find Nodes?
    Voting Booth?