Tim Bunce wrote:

>>>>to take this a step further, what would be really DWIMy is for DBI to clear all of 
>the 
>>>>$dbh attributes not specified in the connect() call (including stuff like 
>LongReadLen) if 
>>>>dbi_connect_method = 'Apache'.  that seems like the right thing, since with 
>Apache::DBI 
>>>>wat we want a "new" $dbh, just without the connect overhead.  and DBI seems like a 
>>>>reasonable place to do it, especially since DBI->connect is kinda 
>action-at-a-distance 
>>>>anyway wrt Apache::DBI.
>>>>
>>>>maybe I'm missing something design-wise, though?
>>>
>>>I think the Apache::DBI subclass can override the STORE method and
>>>track attribute changes itself.
>>
>>That sounds like a good solution. Edmund?
>>
>>I raised this issue, since in the mod_perl book Eric and I are working 
>>on, we say that the connect string shouldn't change in order to be able 
>>to reuse connections.
> 
> 
> s/connect string/connect string and username and password and attributes/ :)
> 
> 
>>I guess we must warn users that any changes to 
>>$dbh will persist, which renders the advisory useless and doesn't 
>>provide any solution :(
> 
> 
> The advisory is still valid - it just needs to be extended so say
> that if they modify an attribute after the connect then they should
> restore it... or wait for a version of Apache::DBI that'll do that for them :)

Thanks Tim,

Is it possible to simply localize the hash elements? Will this work 
properly?

  {
       my $dbh = DBI->connect(@connect) || die $DBI::errstr;

       print "LongReadLen is: ", $dbh->{LongReadLen}, "\n";
       local $dbh->{LongReadLen} = 40;
       print "LongReadLen is now: ", $dbh->{LongReadLen}, "\n";
   }

   my $dbh = DBI->connect(@connect) || die $DBI::errstr;

   print "LongReadLen for new dbh is: ", $dbh->{LongReadLen}, "\n";

If localization works, that's probably the best solution, that can be 
applied by users.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Reply via email to