bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patch #8087] Separate the EOModel connection settings into a different


From: Graham Lee
Subject: [patch #8087] Separate the EOModel connection settings into a different file.
Date: Sat, 22 Jun 2013 15:32:52 +0000
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/536.30.1 (KHTML, like Gecko) Version/6.0.5 Safari/536.30.1

URL:
  <http://savannah.gnu.org/patch/?8087>

                 Summary: Separate the EOModel connection settings into a
different file.
                 Project: GNUstep
            Submitted by: leeg
            Submitted on: Sat 22 Jun 2013 03:32:51 PM GMT
                Category: DevLibs
                Priority: 5 - Normal
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

Hi, this patch stores an EOModel's connection dictionary in
connectionSettings.plist, not in index.eomodeld. I find it easier to
version-control my application source with this patch in place. I can
configure my SCM to ignore the connectionSettings.plist file but still get
updates to the index when I add or remove entities and stored procedures. In
development and production I can supply different connectionSettings.plist
without the SCM thinking there are untracked changes.

Notice that my patch bumps the version number of the file format, I think this
is needed because while this version can load eomodeld bundles created without
this patch, eomodeld bundles _saved_ with this version cannot be loaded
correctly by earlier versions (in fact they'll load but won't have connection
dictionaries).


Index: EOAccess/EOModel.m
===================================================================
--- EOAccess/EOModel.m  (revision 36740)
+++ EOAccess/EOModel.m  (working copy)
@@ -78,7 +78,7 @@
 #include "EOPrivate.h"
 #include "EOAttributePriv.h"
 
-#define DEFAULT_MODEL_VERSION 2
+#define DEFAULT_MODEL_VERSION 3
 
 NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
 
@@ -521,7 +521,21 @@
       propList = [fileContents propertyList];
       EOFLOGObjectLevelArgs(@"gsdb", @"propList=%@", propList);
       NSAssert1(propList!=nil, @"Model at path %@ is invalid", indexPath);
-
+      if([[indexPath pathExtension] isEqualToString: @"eomodeld"])
+       {
+         NSString *connectionPath = [modelPath stringByAppendingPathComponent:
@"connectionSettings.plist"];
+         NSString *externalConnectionSettings = [NSString 
stringWithContentsOfFile:
connectionPath];
+         if (externalConnectionSettings!=nil)
+           {
+             id connectionProperties = [externalConnectionSettings 
propertyList];
+             //copy the original settings and merge the connection settings in
+             NSMutableDictionary *mutableProperties = [propList mutableCopy];
+             [mutableProperties setObject: connectionProperties
+                                   forKey: @"connectionDictionary"];
+             propList = mutableProperties;
+             [mutableProperties autorelease];
+           }
+       }
       self = [self initWithTableOfContentsPropertyList: propList
                    path: modelPath];
       NSAssert2(self!=nil,@"Failed to initialize with path %@ and plist %@",
@@ -754,6 +768,18 @@
       [NSException raise: NSInvalidArgumentException
                   format: fmt];
     }
+  if (writeSingleFile == NO)
+    {
+      NSString *connectionSettingsPath = [path
stringByAppendingPathComponent: @"connectionSettings.plist"];
+      if ([self _writePlist: [self connectionDictionary] toFile:
connectionSettingsPath] == NO)
+       {
+         NSString *fmt;
+         fmt = [NSString stringWithFormat: @"Could not create file: %@",
+                         fileName];
+         [NSException raise: NSInvalidArgumentException
+                     format: fmt];
+       }
+    }
 }
 
 @end
@@ -893,10 +919,6 @@
     [propertyList setObject: _adaptorName
                  forKey: @"adaptorName"];
 
-  if (_connectionDictionary)
-    [propertyList setObject: _connectionDictionary
-                 forKey: @"connectionDictionary"];
-
   if (_userInfo)
     [propertyList setObject: _userInfo
                  forKey: @"userInfo"];





    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/patch/?8087>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]