Re: [Pas-dev] Support for other DBs in the session
Status: Beta
Brought to you by:
mortis
From: Justin B. <ju...@le...> - 2002-05-28 20:02:43
|
>>>>So far, here's my design hack to allow PAS to use other DBs besides MySQL for >>>>it's session. Here's just the package name, the @ISA and the method names: >>> >>>Cool. It looks similar to the road I was going down. I started today on >>>a generic Session and Factory object. The SessionRec can be thrown out >>>and created with one makeGetSetScalar call and reused on any db so long >>>as the column names match. >> >>Yup. >> >> >>>I spaced on a few things and find myself backtracking to fix them. It >>>looks like you're ahead of me. I didnt know you were working on this >>>actively or I'd have mailed you about it. >> >>I was sorta hesitent because I didn't think there was any final approval. I >>think there's more of a hang up on how the whole session is implemented then any >>particular part but it was enough for me to hold off. When it was mentioned >>recently that someone was working on it, I continued down my path. > > Well, originally I was going to just clone mysql stuff and make it work > with postgres. I got pretty far with it, but it was just.... wasteful to > duplicate all that code. Thats when I re-read your proposal and just > started doing it. Your way is much better IMHO. Duplicating all that code == bad. :) >>>I was looking into modifying how session.pm worked to just pick the >>>right kind of object to require and create. Thats about when I realized >>>that the container to use was a config file entry, and backed out a few >>>changes. >> >>Ah. >> >> >>>I guess I'll wait for you to either commit what you have or finish it >>>off. >> >>Well, if people like what I have so far, I'll commit it. >> >>More or less my solution just does a little shuffling: >> >>Org::Bgw::Pas::Session::MySQL -> Org::Bgw::Pas::Session::DB >>Org::Bgw::Pas::Session::MySQL::Factory -> Org::Bgw::Pas::Session::DB::Base > > Yes, and in your config file, you specify what child of these classes to > use, correct? So you'd be setting > pas.session.object=Org::Bgw::Pas::Session::Db::Pg or something right? Pretty much. Every so slightly different. Org::Bgw::Pas::Session::DB determines the correct object to use by what's in the config file. Right now it's reading the variable pas.session.db.driver from the config file. So you pas.session.object will only be valid for the following session types: File, DB or Apache. So if you set pas.session.object to DB, the pas.session.db.driver tells the application what kind of DB the session will be connecting to. >>Small modifications to Org::Bgw::Pas::Session::DB and a new class of >>Org::Bgw::Pas::Session::DB::mysql was all that was needed. >> >>And I guess I should write some unit tests before commiting. ;) I'd also like >>to commit the Postgresql implementation at the same time. I have to remember >>how to configure Postgresql. > > Actually, its not hard. And since its new, it doesnt matter. Just make > sure you dont break mysql and commit what you have. I have postgres > setup and can test/tweak and write tests for that piece if you want. Or > I can create you an account on hades and you can do stuff there. What I meant by configuring is setting up users and then setting passwords & privileges. It's been too long since I've used Postgresql. It's just a matter of finding the right page in the manual. I've created a user, a database and the pas_session table. I'm not sure if I have a password or the privileges right yet. I may also need to upgrade to 7.1 or 7.2 (I'm running 7.0.3 right now). > The way I see this working is that we simply provide a way to get > sessions working in the app. I dont see the DB layer ever doing anything > more. Then developers can write their own page object in pas/pages (or > wherever) that connects to their X database. They would derive from this > OtherDatabase class for their other page objects. This is probably the > most non-invasive/easist way to go. Sessions and other data dont even > need to be in the same db at that point. Forgive me if I'm stating the > obvious, but we may want to add some note to this effect in our docs if > there isnt one already. I guess if we want to go this way, we'd need to change the config file parameter to something closer to what you suggested. Then people can add the different DB session classes outside the Org::Bgw namespace. But I also think it would be good if we could provide support for as many databases as possible (session & other wise). Then at least we can sound kewl and can word salad people with large lists!! Justin |