]> err.no Git - sope/blobdiff - sope-appserver/NGObjWeb/WOApplication.m
minor improvement to WOHttpAdaptor, bumped framework revisions
[sope] / sope-appserver / NGObjWeb / WOApplication.m
index 7dafabd1ff1f2ddad4bb622967e585394d57afd1..a79b58717900cf1707391d9b43ed17946974c167 100644 (file)
@@ -1,20 +1,21 @@
 /*
-  Copyright (C) 2000-2004 SKYRIX Software AG
+  Copyright (C) 2000-2005 SKYRIX Software AG
+  Copyright (C) 2006      Helge Hess
 
-  This file is part of OpenGroupware.org.
+  This file is part of SOPE.
 
-  OGo is free software; you can redistribute it and/or modify it under
+  SOPE is free software; you can redistribute it and/or modify it under
   the terms of the GNU Lesser General Public License as published by the
   Free Software Foundation; either version 2, or (at your option) any
   later version.
 
-  OGo is distributed in the hope that it will be useful, but WITHOUT ANY
+  SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
   WARRANTY; without even the implied warranty of MERCHANTABILITY or
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
   License for more details.
 
   You should have received a copy of the GNU Lesser General Public
-  License along with OGo; see the file COPYING.  If not, write to the
+  License along with SOPE; see the file COPYING.  If not, write to the
   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
   02111-1307, USA.
 */
 #include <NGObjWeb/WOStatisticsStore.h>
 #include <NGObjWeb/WODynamicElement.h>
 #include <NGObjWeb/WOTemplate.h>
-#import <EOControl/EOControl.h>
+#include <EOControl/EOControl.h>
 #include "common.h"
 #include <time.h>
 
+#if GNU_RUNTIME
+#  include <objc/sarray.h>
+#endif
+
 @interface WOApplication(PrivateMethods)
++ (id)logger;
 - (id)_loadComponentDefinitionWithName:(NSString *)_name
   language:(NSArray *)_langs;
 - (NSDictionary *)memoryStatistics;
@@ -56,6 +62,12 @@ static NSString *rapidTurnAroundPath = nil;
 
 @implementation WOApplication
 
+#if 1 // TODO: why is that? why isn't that set by a default?
+static NSString *defaultCompRqHandlerClassName = @"OWViewRequestHandler";
+#else
+static NSString *defaultCompRqHandlerClassName = @"WOComponentRequestHandler";
+#endif
+
 + (int)version {
   return [super version] + 5 /* v6 */;
 }
@@ -68,11 +80,11 @@ static NSString *rapidTurnAroundPath = nil;
   c = [(id<NSObject>)clazz performSelector:@selector(defaultSNSConnection)];
 
   if (c == nil) {
-    [self logFatalWithFormat:@"could not connect SNS, exiting .."];
+    [[self logger] fatalWithFormat:@"could not connect SNS, exiting .."];
     exit(20);
   }
   
-  [self logInfoWithFormat:@"SNS enabled"];
+  [[self logger] logWithFormat:@"SNS enabled"];
 }
 
 + (void)_initializeWOApp {
@@ -89,6 +101,8 @@ static NSString *rapidTurnAroundPath = nil;
   debugOn = [WOApplication isDebuggingEnabled];
   if (!debugOn)
     [[self logger] setLogLevel:NGLogLevelInfo];
+  else
+    NSLog(@"Note: WOApplication debugging is enabled.");
 
   if (classLock == nil) classLock = [[NSRecursiveLock alloc] init];
   ud = [NSUserDefaults standardUserDefaults];
@@ -98,7 +112,7 @@ static NSString *rapidTurnAroundPath = nil;
   if ([ud boolForKey:@"WOContactSNS"])
     [self _setupSNS];
   else
-    [self logInfoWithFormat:@"SNS support disabled."];
+    [[self logger] logWithFormat:@"SNS support disabled."];
   
   NSDateClass = [NSDate class];
   WOTemplateClass = [WOTemplate class];
@@ -179,7 +193,7 @@ static NSString *rapidTurnAroundPath = nil;
       
       pi  = [NSProcessInfo processInfo];
       env = [pi environment];
-      if ([env objectForKey:@"GNUSTEP_SYSTEM_ROOT"] != nil) {
+      if ([[env objectForKey:@"GNUSTEP_SYSTEM_ROOT"] isNotNull]) {
        isFlattened = [[[env objectForKey:@"GNUSTEP_FLATTENED"]
                              lowercaseString] isEqualToString:@"yes"];
       }
@@ -226,7 +240,7 @@ static NSString *rapidTurnAroundPath = nil;
   e    = [keys objectEnumerator];
   while((key = [e nextObject]) != nil) {
     if ([key hasPrefix:@"WO"] || [key isEqualToString:@"NSProjectSearchPath"])
-      [self logInfoWithFormat:@"[default]: %@ = %@",
+      [self logWithFormat:@"[default]: %@ = %@",
         key,
         [[ud objectForKey:key] description]];
   }
@@ -235,7 +249,7 @@ static NSString *rapidTurnAroundPath = nil;
 - (id)initWithName:(NSString *)_name {
   [WOApplication _initializeWOApp];
   
-  if ((self = [super init])) {
+  if ((self = [super init]) != nil) {
     NSUserDefaults   *ud;
     WORequestHandler *rh;
     NSString *rk;
@@ -262,25 +276,26 @@ static NSString *rapidTurnAroundPath = nil;
     self->requestHandlerRegistry =
       NSCreateMapTable(NSObjectMapKeyCallBacks, NSObjectMapValueCallBacks, 8);
     
-    rk = [WOApplication componentRequestHandlerKey];
-#if 1
-    rh = [[NSClassFromString(@"OWViewRequestHandler") alloc] init];
-#else
-    rh = [[NSClassFromString(@"WOComponentRequestHandler") alloc] init];
-#endif
-    if ([rk length] > 0 && (rh != nil))
+    if ((rk = [WOApplication componentRequestHandlerKey]) == nil) {
+      [self logWithFormat:
+             @"WARNING: no component request handler key is specified, "
+             @"this probably means that share/ngobjweb/Defaults.plist "
+             @"could not get loaded (permissions?)"];
+    }
+    rh = [[NSClassFromString(defaultCompRqHandlerClassName) alloc] init];
+    if ([rk isNotEmpty] && [rh isNotNull])
       [self registerRequestHandler:rh forKey:rk];
     [rh release]; rh = nil;
     
     rk = [WOApplication directActionRequestHandlerKey];
     rh = [[NSClassFromString(@"WODirectActionRequestHandler") alloc] init];
-    if ([rk length] > 0 && rh != nil)
+    if ([rk isNotEmpty] && [rh isNotNull])
       [self registerRequestHandler:rh forKey:rk];
     [rh release]; rh = nil;
     
     if ((rh = [[NSClassFromString(@"WOResourceRequestHandler") alloc] init])) {
       rk = [WOApplication resourceRequestHandlerKey];
-      if ([rk length] > 0)
+      if ([rk isNotEmpty])
         [self registerRequestHandler:rh forKey:rk];
       [self registerRequestHandler:rh forKey:@"WebServerResources"];
 #ifdef __APPLE__
@@ -345,7 +360,7 @@ static NSString *rapidTurnAroundPath = nil;
 
 - (void)processHupSignal:(int)_signal {
   /* this isn't called immediatly */
-  [self logInfoWithFormat:@"terminating on SIGHUP ..."];
+  [self logWithFormat:@"terminating on SIGHUP ..."];
   [self terminate];
 }
 
@@ -364,7 +379,7 @@ static NSString *rapidTurnAroundPath = nil;
   
   if (self->path == nil) {
     if ((self->path = [[self _lookupAppPath] copy]) == nil) {
-      [self logDebugWithFormat:@"could not find wrapper of application !"];
+      [self debugWithFormat:@"could not find wrapper of application !"];
       missingPath = YES;
       return nil;
     }
@@ -407,11 +422,11 @@ static NSString *rapidTurnAroundPath = nil;
   NSDictionary *td;
   
   if ((t = [NSThread currentThread]) == nil) {
-    [self logErrorWithFormat:@"missing current thread !!!"];
+    [self errorWithFormat:@"missing current thread !!!"];
     return nil;
   }
   if ((td = [t threadDictionary]) == nil) {
-    [self logErrorWithFormat:
+    [self errorWithFormat:
             @"missing current thread's dictionary (thread=%@) !!!",
             t];
     return nil;
@@ -488,7 +503,7 @@ static NSString *rapidTurnAroundPath = nil;
   WOSession *sn;
 
   sn = [self createSessionForRequest:[_ctx request]];
-  [_ctx setSession:sn];
+  [_ctx setNewSession:sn];
   
   if ([sn respondsToSelector:@selector(prepare)]) {
 #if DEBUG
@@ -511,24 +526,24 @@ static NSString *rapidTurnAroundPath = nil;
   if (_request == nil) return nil;
   
   /* first look into form values */
-  if ((sessionId = [_request formValueForKey:WORequestValueSessionID])) {
-    if ([sessionId length] > 0)
+  if ((sessionId = [_request formValueForKey:WORequestValueSessionID])!=nil) {
+    if ([sessionId isNotEmpty])
       return sessionId;
   }
   
   /* now look into the cookies */
-  if ((sessionId = [_request cookieValueForKey:[self name]])) {
+  if ((sessionId = [_request cookieValueForKey:[self name]]) != nil) {
     if ([sessionId respondsToSelector:@selector(objectEnumerator)]) {
       NSEnumerator *e;
       
       e = [(id)sessionId objectEnumerator];
-      while ((sessionId = [e nextObject])) {
-        if ([sessionId length] > 0 && ![sessionId isEqual:@"nil"])
+      while ((sessionId = [e nextObject]) != nil) {
+        if ([sessionId isNotEmpty] && ![sessionId isEqual:@"nil"])
           return sessionId;
       }
     }
     else {
-      if ([sessionId length] > 0 && ![sessionId isEqual:@"nil"])
+      if ([sessionId isNotEmpty] && ![sessionId isEqual:@"nil"])
         return sessionId;
     }
   }
@@ -543,17 +558,17 @@ static NSString *rapidTurnAroundPath = nil;
   unsigned char buf[20];
   
   sessionCount++;
-  sprintf(buf, "%04X%04X%02X%08X",
+  sprintf((char *)buf, "%04X%04X%02X%08X",
           [[self number] intValue], getpid(), sessionCount, 
           (unsigned int)time(NULL));
-  wosid = [NSString stringWithCString:buf];
+  wosid = [NSString stringWithCString:(char *)buf];
   return wosid;
 }
 
-- (WOSession *)createSessionForRequest:(WORequest *)_request {
+- (id)createSessionForRequest:(WORequest *)_request {
   if ([self respondsToSelector:@selector(createSession)]) {
     /* call deprecated method */
-    [self logWarnWithFormat:@"calling deprecated -createSession .."];
+    [self warnWithFormat:@"calling deprecated -createSession .."];
     return [self createSession];
   }
   else {
@@ -566,16 +581,14 @@ static NSString *rapidTurnAroundPath = nil;
   }
 }
 
-- (WOSession *)restoreSessionWithID:(NSString *)_sid
-  inContext:(WOContext *)_ctx
-{
+- (id)restoreSessionWithID:(NSString *)_sid inContext:(WOContext *)_ctx {
   WOSession *session;
   
   *(&session) = nil;
 
   if ([self respondsToSelector:@selector(restoreSession)]) {
     /* call deprecated method */
-    [self logWarnWithFormat:@"calling deprecated -restoreSession .."];
+    [self warnWithFormat:@"calling deprecated -restoreSession .."];
     return [self restoreSession];
   }
   
@@ -583,11 +596,11 @@ static NSString *rapidTurnAroundPath = nil;
     WOSessionStore *store;
     
     if ((store = [self sessionStore]) == nil) {
-      [self logErrorWithFormat:@"missing session store ..."];
+      [self errorWithFormat:@"missing session store ..."];
     }
     else {
       session = [store restoreSessionWithID:_sid request:[_ctx request]];
-      if (session) {
+      if ([session isNotNull]) {
         [_ctx setSession:session];
         [session _awakeWithContext:_ctx];
       }
@@ -612,7 +625,7 @@ static NSString *rapidTurnAroundPath = nil;
       if ([sid respondsToSelector:@selector(objectEnumerator)]) {
         NSEnumerator *e;
         
-        [self logErrorWithFormat:@"got multiple session IDs !"];
+        [self errorWithFormat:@"got multiple session IDs !"];
         
         e = [sid objectEnumerator];
         while ((_sid = [e nextObject])) {
@@ -622,7 +635,7 @@ static NSString *rapidTurnAroundPath = nil;
           if ((session = [self restoreSessionWithID:_sid inContext:_ctx]))
             return session;
           
-          //NSLog(@"WARNING: did not find session for sid %@", _sid);
+          //[self warnWithFormat:@"did not find session for sid %@", _sid);
         }
       }
     }
@@ -637,7 +650,7 @@ static NSString *rapidTurnAroundPath = nil;
   
   if ([self respondsToSelector:@selector(saveSession:)]) {
     /* call deprecated method */
-    [self logWarnWithFormat:@"calling deprecated -saveSession: .."];
+    [self warnWithFormat:@"calling deprecated -saveSession: .."];
     [self saveSession:[_ctx session]];
     return;
   }
@@ -657,7 +670,7 @@ static NSString *rapidTurnAroundPath = nil;
     if (perfLogger) {
       NSTimeInterval rt;
       rt = [[NSDateClass date] timeIntervalSince1970] - startSnSleep;
-      [perfLogger logInfoWithFormat:@"[woapp]: session -sleep took %4.3fs.",
+      [perfLogger logWithFormat:@"[woapp]: session -sleep took %4.3fs.",
                                     rt < 0.0 ? -1.0 : rt];
     }
     
@@ -676,7 +689,7 @@ static NSString *rapidTurnAroundPath = nil;
     if (perfLogger) {
       NSTimeInterval rt;
       rt = [[NSDateClass date] timeIntervalSince1970] - startStore;
-      [perfLogger logInfoWithFormat:@"[woapp]: storing sn in store took %4.3fs.",
+      [perfLogger logWithFormat:@"[woapp]: storing sn in store took %4.3fs.",
                                     rt < 0.0 ? -1.0 : rt];
     }
   }
@@ -685,7 +698,7 @@ static NSString *rapidTurnAroundPath = nil;
   if (perfLogger) {
     NSTimeInterval rt;
     rt = [[NSDateClass date] timeIntervalSince1970] - startSave;
-    [perfLogger logInfoWithFormat:@"[woapp]: saveSessionForContext took %4.3fs.",
+    [perfLogger logWithFormat:@"[woapp]: saveSessionForContext took %4.3fs.",
                                   rt < 0.0 ? -1.0 : rt];
   }
 }
@@ -739,7 +752,7 @@ static NSString *rapidTurnAroundPath = nil;
   }
 }
 
-- (WOSession *)session {
+- (id)session {
   return [[self context] session];
 }
 
@@ -754,11 +767,11 @@ static NSString *rapidTurnAroundPath = nil;
 #endif
   
   if ([self respondsToSelector:@selector(handleSessionCreationError)]) {
-    [self logWarnWithFormat:@"called deprecated -handleSessionCreationError method"];
+    [self warnWithFormat:@"called deprecated -handleSessionCreationError method"];
     return [self handleSessionCreationError];
   }
   
-  [self logErrorWithFormat:@"could not create session for context %@", _ctx];
+  [self errorWithFormat:@"could not create session for context %@", _ctx];
   
   [response setStatus:200];
   [response appendContentString:@"<h4>Session Creation Error</h4>\n<pre>"];
@@ -784,12 +797,14 @@ static NSString *rapidTurnAroundPath = nil;
 
 - (WOResponse *)handleSessionRestorationErrorInContext:(WOContext *)_ctx {
   if ([self respondsToSelector:@selector(handleSessionRestorationError)]) {
-    [self logWarnWithFormat:@"calling deprecated "
+    [self warnWithFormat:@"calling deprecated "
                             @"-handleSessionRestorationError method"];
     return [self handleSessionRestorationError];
   }
   
-  [self logErrorWithFormat:@"could not restore session for context %@", _ctx];
+  // TODO: is it correct to return nil?
+  // TODO: we should return a page saying sorry with a cookie + redirect
+  [self errorWithFormat:@"could not restore session for context %@", _ctx];
   return nil;
 }
 
@@ -808,23 +823,38 @@ static NSString *rapidTurnAroundPath = nil;
 
 /* resources */
 
+- (void)_setupDefaultResourceManager {
+  NSUserDefaults *ud;
+  Class    rmClass;
+  NSString *p;
+  
+  ud = [NSUserDefaults standardUserDefaults];
+  p  = [ud stringForKey:@"WODefaultResourceManager"];
+  rmClass = [p isNotEmpty]
+    ? NSClassFromString(p)
+    : [WOResourceManager class];
+  
+  if (rmClass == Nil) {
+    [self errorWithFormat:
+            @"failed to locate class of resource manager: '%@'", p];
+    return;
+  }
+  
+  if ([rmClass instancesRespondToSelector:@selector(initWithPath:)])
+    self->resourceManager = [[rmClass alloc] init];
+  else {
+    self->resourceManager = 
+      [(WOResourceManager *)[rmClass alloc] initWithPath:[self path]];
+  }
+}
+
 - (void)setResourceManager:(WOResourceManager *)_manager {
   ASSIGN(self->resourceManager, _manager);
 }
 - (WOResourceManager *)resourceManager {
-  if (self->resourceManager == nil) {
-    NSString *p;
-
-#if 0 && DEBUG
-    if ([(p = [self path]) length] > 0)
-      [self logDebugWithFormat:@"setup WOResourceManager at path '%@' ...", p];
-#else
-    p = [self path];
-#endif
-    
-    self->resourceManager = 
-      [(WOResourceManager *)[WOResourceManager alloc] initWithPath:p];
-  }
+  if (self->resourceManager == nil)
+    [self _setupDefaultResourceManager];
+  
   return self->resourceManager;
 }
 
@@ -860,6 +890,17 @@ static NSString *rapidTurnAroundPath = nil;
 - (void)awake {
 }
 - (void)sleep {
+#if DEBUG && PRINT_NSSTRING_STATISTICS
+  if ([NSString respondsToSelector:@selector(printStatistics)])
+    [NSString printStatistics];
+#endif
+  
+#if DEBUG && PRINT_OBJC_STATISTICS
+extern int __objc_selector_max_index;
+  printf("nbuckets=%i, nindices=%i, narrays=%i, idxsize=%i\n",
+nbuckets, nindices, narrays, idxsize);
+  printf("maxsel=%i\n", __objc_selector_max_index);
+#endif
 }
 
 /* responder */
@@ -870,7 +911,7 @@ static NSString *rapidTurnAroundPath = nil;
   else {
     WOComponent *page;
     
-    if ((page = [_ctx page])) {
+    if ((page = [_ctx page]) != nil) {
       WOContext_enterComponent(_ctx, page, nil);
       [page takeValuesFromRequest:_req inContext:_ctx];
       WOContext_leaveComponent(_ctx, page);
@@ -940,11 +981,11 @@ static NSString *rapidTurnAroundPath = nil;
   Class     dynamicElementClass = NSClassFromString(_name);
 
   if (dynamicElementClass == Nil) {
-    [self logWarnWithFormat:@"did not find dynamic element class %@ !", _name];
+    [self warnWithFormat:@"did not find dynamic element class %@ !", _name];
     return nil;
   }
   if (![dynamicElementClass isDynamicElement]) {
-    [self logWarnWithFormat:@"class %@ is not a dynamic element class !", _name];
+    [self warnWithFormat:@"class %@ is not a dynamic element class !", _name];
     return nil;
   }
   
@@ -994,7 +1035,7 @@ static NSString *rapidTurnAroundPath = nil;
   return self->permanentPageCacheSize;
 }
 
-- (WOComponent *)pageWithName:(NSString *)_name {
+- (id)pageWithName:(NSString *)_name {
   // deprecated in WO4
   return [self pageWithName:_name inContext:[self context]];
 }
@@ -1021,17 +1062,24 @@ static NSString *rapidTurnAroundPath = nil;
   start = [self memoryStatistics];
 #endif
   
-  pool = [[NSAutoreleasePool alloc] init];
+  pool      = [[NSAutoreleasePool alloc] init];
   
-  languages = [_ctx hasSession]
-    ? [(WOSession *)[_ctx session] languages]
-    : [[_ctx request] browserLanguages];
+  languages = [_ctx resourceLookupLanguages];
 
   if ((rm = [[_ctx component] resourceManager]) == nil)
     rm = [self resourceManager];
   
-  page = [rm pageWithName:(_name != nil ? _name : @"Main")
-             languages:languages];
+  /*  TODO:
+   *  the following ignores the fact that the passed context may be different
+   *  from that of WOApplication. During the course of template instantiation
+   *  WOApplication's current context gets attached to page which is definitely
+   *  wrong. We workaround this problem by using the private API of WOComponent
+   *  to explicitly set it. However all accompanied methods should be
+   *  extended to pass the correct context where needed.
+   */
+  page      = [rm pageWithName:(_name != nil ? _name : @"Main")
+                  languages:languages];
+  [page _setContext:_ctx];
   [page ensureAwakeInContext:_ctx];
   
   page = [page retain];
@@ -1047,17 +1095,17 @@ static NSString *rapidTurnAroundPath = nil;
              [[start objectForKey:@"VmSize"] intValue];
     lib    = [[stop objectForKey:@"VmLib"] intValue] -
              [[start objectForKey:@"VmLib"] intValue];
-    [self logDebugWithFormat:@"loaded component %@; rss=%i vm=%i lib=%i.",
-      _name, rss,vmsize,lib];
+    [self debugWithFormat:@"loaded component %@; rss=%i vm=%i lib=%i.",
+            _name, rss,vmsize,lib];
   }
 #endif
   
   return [page autorelease];
 }
-- (WOComponent *)pageWithName:(NSString *)_name inContext:(WOContext *)_ctx {
+- (id)pageWithName:(NSString *)_name inContext:(WOContext *)_ctx {
   return [self _pageWithName:_name inContext:_ctx];
 }
-- (WOComponent *)pageWithName:(NSString *)_name forRequest:(WORequest *)_req {
+- (id)pageWithName:(NSString *)_name forRequest:(WORequest *)_req {
   WOResourceManager *rm;
 
   if ((rm = [self resourceManager]) == nil)
@@ -1077,7 +1125,7 @@ static NSString *rapidTurnAroundPath = nil;
 }
 
 - (WOResponse *)handlePageRestorationErrorInContext:(WOContext *)_ctx {
-  [self logErrorWithFormat:
+  [self errorWithFormat:
           @"could not restore page for context-id %@\n  in context %@",
           [_ctx currentElementID], _ctx];
   
@@ -1098,7 +1146,7 @@ static NSString *rapidTurnAroundPath = nil;
   WOResponse *r  = nil;
   
   if ([self respondsToSelector:@selector(handleException:)]) {
-    [self logWarnWithFormat:@"calling deprecated -handleException method !"];
+    [self warnWithFormat:@"calling deprecated -handleException method !"];
     return [self handleException:_exc];
   }
   
@@ -1111,21 +1159,21 @@ static NSString *rapidTurnAroundPath = nil;
        ? 1 : 0;
     }
     if (doCore) {
-      [self logFatalWithFormat:@"%@: caught (ctx=%@):\n  %@.",
-           self, _ctx, _exc];
+      [self fatalWithFormat:@"%@: caught (ctx=%@):\n  %@.",
+              self, _ctx, _exc];
       abort();
     }
   }
 #endif
   
   if (_ctx == nil) {
-    [self logFatalWithFormat:@"%@: caught (without context):\n  %@.",
-                             self, _exc];
+    [self fatalWithFormat:@"%@: caught (without context):\n  %@.",
+            self, _exc];
     [self terminate];
   }
   else if (rq == nil) {
-    [self logFatalWithFormat:@"%@: caught (without request):\n  %@.",
-                             self, _exc];
+    [self fatalWithFormat:@"%@: caught (without request):\n  %@.",
+            self, _exc];
     [self terminate];
   }
   else {
@@ -1143,7 +1191,7 @@ static NSString *rapidTurnAroundPath = nil;
     NSString *str = nil;
     NSString *bt  = nil;
     
-    [self logErrorWithFormat:@"%@: caught:\n  %@\nin context:\n  %@.",
+    [self errorWithFormat:@"%@: caught:\n  %@\nin context:\n  %@.",
             self, _exc, _ctx];
 
 #if LIB_FOUNDATION_LIBRARY
@@ -1152,11 +1200,11 @@ static NSString *rapidTurnAroundPath = nil;
 #endif
     
     if ((r = [WOResponse responseWithRequest:rq]) == nil)
-      [self logErrorWithFormat:@"could not create response !"];
+      [self errorWithFormat:@"could not create response !"];
     
     [r setHeader:@"text/html" forKey:@"content-type"];
     [r setHeader:@"no-cache" forKey:@"cache-control"];
-    if(rapidTurnAroundPath != nil) {
+    if (rapidTurnAroundPath != nil) {
         NSURL *templateURL;
         
         templateURL = [[_exc userInfo] objectForKey:@"templateURL"];
@@ -1227,7 +1275,7 @@ static NSString *rapidTurnAroundPath = nil;
 
 #if !LIB_FOUNDATION_LIBRARY
 - (id)valueForUndefinedKey:(NSString *)_key {
-  [self logWarnWithFormat:@"tried to access undefined KVC key: '%@'",
+  [self warnWithFormat:@"tried to access undefined KVC key: '%@'",
          _key];
   return nil;
 }
@@ -1240,7 +1288,8 @@ static NSString *rapidTurnAroundPath = nil;
   static BOOL  lookedUpForEOEditingContextClass = NO;
   
   if (!lookedUpForEOEditingContextClass) {
-    eoEditingContextClass = NSClassFromString(@"EOEditingContext");
+    if ((eoEditingContextClass = NSClassFromString(@"EOEditingContext")) ==nil)
+      eoEditingContextClass = NSClassFromString(@"NSManagedObjectContext");
     lookedUpForEOEditingContextClass = YES;
   }
   return eoEditingContextClass;