From: helge Date: Sat, 20 Nov 2004 23:37:09 +0000 (+0000) Subject: minor code cleanups X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ca2a3b90d7c05469d589e91b63850b78c710cfa;p=sope minor code cleanups git-svn-id: http://svn.opengroupware.org/SOPE/trunk@404 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-appserver/NGObjWeb/ChangeLog b/sope-appserver/NGObjWeb/ChangeLog index 97c6b243..40cb1bc5 100644 --- a/sope-appserver/NGObjWeb/ChangeLog +++ b/sope-appserver/NGObjWeb/ChangeLog @@ -1,3 +1,7 @@ +2004-11-21 Helge Hess + + * WODirectActionRequestHandler.m: minor code cleanups (v4.5.96) + 2004-11-19 Marcus Mueller * v4.5.95 diff --git a/sope-appserver/NGObjWeb/Version b/sope-appserver/NGObjWeb/Version index cfdbb476..2949dc7a 100644 --- a/sope-appserver/NGObjWeb/Version +++ b/sope-appserver/NGObjWeb/Version @@ -1,6 +1,6 @@ # version file -SUBMINOR_VERSION:=95 +SUBMINOR_VERSION:=96 # v4.5.91 requires libNGExtensions v4.5.134 # v4.5.84 requires libNGExtensions v4.5.127 diff --git a/sope-appserver/NGObjWeb/WODirectActionRequestHandler.m b/sope-appserver/NGObjWeb/WODirectActionRequestHandler.m index a73aa380..02ee62fa 100644 --- a/sope-appserver/NGObjWeb/WODirectActionRequestHandler.m +++ b/sope-appserver/NGObjWeb/WODirectActionRequestHandler.m @@ -36,24 +36,25 @@ # include #endif +static BOOL usePool = NO; static BOOL perflog = NO; +static BOOL debugOn = NO; static Class NSDateClass = Nil; -//#define USE_POOLS 1 - @implementation WODirectActionRequestHandler + (int)version { return [super version] + 0 /* 2 */; } + (void)initialize { + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + NSAssert2([super version] == 2, @"invalid superclass (%@) version %i !", NSStringFromClass([self superclass]), [super version]); NSDateClass = [NSDate class]; - perflog = [[NSUserDefaults standardUserDefaults] - boolForKey:@"WOProfileDirectActionRequestHandler"]; + perflog = [ud boolForKey:@"WOProfileDirectActionRequestHandler"]; } - (NSString *)loggingPrefix { @@ -62,14 +63,14 @@ static Class NSDateClass = Nil; /* The request handler part of a direct action URI looks like this: - + [actionClass/]actionName[?key=value&key=value&...] */ - (BOOL)isComponentClass:(Class)_clazz { if (_clazz == Nil) return NO; - while ((_clazz = _clazz->super_class)) { + while ((_clazz = _clazz->super_class) != Nil) { if (_clazz == [WOComponent class]) return YES; if (_clazz == [WODirectAction class]) return NO; if (_clazz == [NSObject class]) return NO; @@ -85,6 +86,7 @@ static Class NSDateClass = Nil; if (actionClass == Nil) return nil; + if (![self isComponentClass:actionClass]) { /* create direct action object */ id actionObject; @@ -121,16 +123,16 @@ static Class NSDateClass = Nil; session:(WOSession *)session application:(WOApplication *)app { -#if USE_POOLS - NSAutoreleasePool *pool2 = [[NSAutoreleasePool alloc] init]; -#endif - NSString *actionClassName; - NSString *actionName; - WOResponse *response; - NSArray *handlerPath; - Class actionClass = Nil; + NSAutoreleasePool *pool2; + NSString *actionClassName; + NSString *actionName; + WOResponse *response; + NSArray *handlerPath; + Class actionClass = Nil; WODirectAction *actionObject = nil; id result = nil; + + pool2 = usePool ? [[NSAutoreleasePool alloc] init] : nil; *(&result) = nil; *(&response) = nil; @@ -142,11 +144,12 @@ static Class NSDateClass = Nil; handlerPath = [_request requestHandlerPathArray]; -#if DEBUG_DIRECT_ACTION - [self debugWithFormat:@"path=%@ array=%@", + if (debugOn) { + [self debugWithFormat:@"path=%@ array=%@", [_request requestHandlerPath], handlerPath]; -#endif - + } + + // TODO: fix OGo bug #1028 switch ([handlerPath count]) { case 0: actionClassName = @"DirectAction"; @@ -164,10 +167,11 @@ static Class NSDateClass = Nil; default: actionClassName = [handlerPath objectAtIndex:0]; actionName = [handlerPath objectAtIndex:1]; -#if 0 - NSLog(@"invalid direction action URL: %@", - [_request requestHandlerPath]); -#endif + // TODO: set path info in ctx? + if (debugOn) { + [self logWithFormat:@"invalid direction action URL: %@", + [_request requestHandlerPath]]; + } break; } @@ -180,11 +184,11 @@ static Class NSDateClass = Nil; actionClass = [WODirectAction class]; } -#if DEBUG_DIRECT_ACTION - [self debugWithFormat: - @"[direct action request handler] class=%@ action=%@ ..", - actionClassName, actionName]; -#endif + if (debugOn) { + [self debugWithFormat: + @"[direct action request handler] class=%@ action=%@ ..", + actionClassName, actionName]; + } /* process request */ @@ -238,11 +242,11 @@ static Class NSDateClass = Nil; [session lock]; } -#if USE_POOLS - session = [session retain]; - [pool2 release]; pool2 = nil; - session = [session autorelease]; -#endif + if (usePool) { + session = [session retain]; + [pool2 release]; pool2 = nil; + session = [session autorelease]; + } response = [response autorelease]; }