[rt-devel] Accessing a second database (updated)

Bart Duchesne bduc at dyndaco.com
Mon May 6 14:51:43 EDT 2002

Bart Duchesne wrote:

>Hi all,
>We are currently running RT 2.0.13 successfully for several weeks now
>and I'm making some customisations for it.
>Take a seat as the problem description is rather long, but tested.
>What I have done is the following :
>I made a class hierarchy of my company database (Postgress; running on a
>different machine then RT in a different database) the same way it is
>done in RT (using DBIx::SearchBuilder::Handle, Dx::S::Record , etc)
>I have a test perl script using these objects successfully from the
>commandline; so access to the database is ok and the objects really
>Then I added my modules to the RT lib directory, modified the webmux  to
>also use my modules and called MYDB::Init() right after RT::Init().
>This is where trouble starts, it appears to me that the Dx::S::Handle
>uses a global $DBIHandle that is overwritten each time Handle->Connect
>is called: the call to RT::Init messes up the handle made by MYDB::Init,
>so it's tables are unacessible because the handle it has constructed now
>points to the RT database instead of mine.
>Trying to be smart, I modified Dx::S::Handle and made the $DBIHandle  a
>instance variable, I modified the Handle->dbh function to store in the
>$self hash.
>At a first sight it worked, I can access my two databases now using the
>objects, BUT after a while I get a an error when RT tries to use the
>$session{tickets} object, it's database handle has become invalid. When
>not using these $session{tickets} everything works nicely.
My guess was right ! It has something to do with the 'caching' of the 
DBI handle in the tickets object in the $session{tickets} object,
I changed the way the RT:EasySearch get's its handle (through a method 
call instead of getting it from it's hash) and now everything works 
fine, the restored tickets object now get's a new and fresh DBI handle 
from RT::Handle that never barks to me.
The global DBIHandle in DBIx::SearchBuilder::Handle is now not being 
used anymore (handle is stored in it's hash) and I can now run two 
different database apps in the same Mason (RT and our own 
Company-Database-Extension-to-RT  )
If anyone is intrested in the changes please let me know then I will 
post them to the list.



>Can someone help me out, I'm lost ...
>Bart  Duchesne
>bduc at dyndaco.com
>rt-devel mailing list
>rt-devel at lists.fsck.com

More information about the Rt-devel mailing list