Re: Connecting to deployment database for development/testing
Re: Connecting to deployment database for development/testing
- Subject: Re: Connecting to deployment database for development/testing
- From: "Tanmoy Roy" <email@hidden>
- Date: Wed, 29 Mar 2006 16:40:05 -0800
Hi Zak,
I am really fascinated by the way you have handled the connections in
EOModel. I have couple of questions regarding this :
1) Going by your code it seems that we can change the connection
dictionary at run-time. Am I correct ?
2) If #1 is correct and as far as my little knowledge of WO and
EOModel goes we need to start and stop the app. instances in the
monitor for any change in the EOModel to be visible. Can you please
tell me am I correct here?
Now a small request. Can you give me a code piece where you have
implemented the concept that you have mentioned.
Thanks and best regards,
Tanmoy
On 3/28/06, Zak Burke <email@hidden> wrote:
> John Huss wrote on 3/28/06 10:23 AM:
> > I was curious how most of you specify the URL of your database in
> > EOModeler. Do you use localhost, etc, or the actual address of the
> > server? What I mean is, do you connect to the production database
> > while developing and/or testing, or do you just use a local version?
>
> I connect to localhost and use an external properties file to replace
> the DB connection properties (username, password). For example, an app's
> internal Properties file will contain only a single line:
>
> props.path = /var/app_dir/app.properties
>
> and the actual properties are all in app.properties. That file path,
> /var/app_dir/app.properties, exists on both my dev and production
> machines. By keeping an application's runtime props in a file that isn't
> affected by each deployment, I don't have to worry about deploying an
> app and forgetting to change its settings from dev to production.
>
> Specifically WRT model parameters, my app.properties file contains the
> following:
>
> modelname.username = dbuser
> modelname.password = dbpassword
> modelname.database = dbname
>
> and I have the following method in Application.java. I suppose I could
> add a modelname.URL param as well to point to an external DB, but I
> haven't tried that.
>
> /**
> * Intercept add-model notifications and reset the authentication
> * fields in the model's connection dictionary if System.properties
> * contains a username and password for this model.
> *
> * @param notification container for EOModel being added
> */
> public void receiveModelAddedNotification(NSNotification notification)
> {
> EOModel model = (EOModel) notification.object();
>
> String username = System.getProperty(model.name() + ".username");
> String password = System.getProperty(model.name() + ".password");
>
> if (username != null && password != null)
> {
> NSMutableDictionary connD =
> model.connectionDictionary().mutableClone();
>
> connD.setObjectForKey( username, "username");
> connD.setObjectForKey( password, "password");
>
> model.setConnectionDictionary(connD);
> }
> }
>
> HTH,
>
> zak.
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
--
Best,
Tanmoy
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden