perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luiz Fernando B. Ribeiro" <>
Subject Re: Is there a point in using the request object for db connections when using Apache::DBI?
Date Wed, 14 Jul 2004 12:29:07 GMT
On Tue, 13 Jul 2004 15:07:30 -0700, John P. Gibbons <>

> I was reading this article:  
> and of course this  
> mailing list and have seen reference to people using the $req object to  
> have one database connection.
> On my sites I did not do it that way. I use Apache::DBI to handle the  
> DBI connection issue and do a separate connects  in my base.html and in  
> all other referenced Embperl files/code. Apache::DBI of course makes  
> sure we really only have one connection per httpd, as you all know.
> I was wondering if there is any benefit or reason to use the request  
> object method in my scenario? I'm looking at ways to optimize my code as  
> it has grown dramatically and this has been in the back of my mind for  
> awhile. I remember reading something that in order to give db access to  
> an include embperl file with only subroutines you'd have to use that  
> method. But I can't recall now. I was also thinking that there are cases  
> when I call .epl files directly and do not want them wrapped in  
> base.html. If I were to use the request object method then I would  
> either be out of luck or would have to code around it somehow.

The request object can be useful to share variables across pages during
_that_ request.

For big projects the recommended solution is to abstract the logic and
database operations into a module and let Embperl handle the interface

If you use EmbperlObject you can instantiate your class in your template
file, usually base.epr, and share the object across the other
pages/components _in that request_ using the request object. I think this
is a better approach than to use global class variables.

Unless you known what you are doing do not use your own namespace across
pages to be able to share variables. The same applies to CLEANUP. Embperl
handles the namespace and encapsulates each page to avoid leaks and

I recommend you to read about EmbperlObject since it has many features to
improve your application design.

Luiz Fernando B. Ribeiro
Engenho Soluções para a Internet
+55 11 4485-0136

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message