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 protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to