On 10/23/07, Perrin Harkins <[EMAIL PROTECTED]> wrote:
> On 10/23/07, John Siracusa <[EMAIL PROTECTED]> wrote:
> > I've had some bad experiences with passing database handles around in
> > pnotes.
>
> It should be safe to do that.  One thing to remember is that pnotes
> takes an alias to what you pass in, not a copy.  If you feed it $foo
> and then change the value of $foo, the value in pnotes changes too.
>
> - Perrin
>

Thank you all for the comments. Replacing

    $r->pnotes( dbh      => My::DB->new->dbh);

with

    my $dbh = DBI->connect("dbi:Pg:dbname=dev", "dev", "");
    $r->pnotes( dbh      => $dbh );

solved the issue. Doing connect_on_init() and still getting the dbh
from My::DB solves the issue as well (per Philip's suggestion). Does
Rose::DB bypass Apache::DBI if connect_on_init() hasn't been called?

Still not sure what exactly causes the issue in the first place though.

John, thanks for sharing your init_db() code. I guess the point of
caching the db handle in Rose::DB::Object in addition to the caching
done by Apache::DBI, is to ensure that all the Rose objects share the
same connection within each Apache child process. As you guessed,
using that code by itself (without the above fixes) didn't solve the
issue.

Reply via email to