Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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

by Sifmole (Chaplain)
on Jun 16, 2004 at 17:59 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://367342]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (11)
As of 2024-04-19 16:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found