Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

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 "FOO.bar" 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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://367342]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (13)
As of 2014-09-22 12:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (191 votes), past polls