Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
+// $Id: WOValueAssociation.h 1 2004-08-20 10:08:27Z znek $
#ifndef __NGObjWeb_WOValueAssociation_H__
#define __NGObjWeb_WOValueAssociation_H__
#include <NGObjWeb/WOAssociation.h>
+/*
+ WOValueAssociation
+
+ Represents a constant value.
+*/
+
@interface WOValueAssociation : WOAssociation < NSCoding, NSCopying >
{
id value;
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
#include "WOValueAssociation.h"
#include "common.h"
@implementation WOValueAssociation
+static Class StrClass = Nil;
+
+ (int)version {
return [super version] /* v2 */;
}
NSAssert2([super version] == 2,
@"invalid superclass (%@) version %i !",
NSStringFromClass([self superclass]), [super version]);
+ StrClass = [NSString class];
}
+ (WOAssociation *)associationWithValue:(id)_value {
case 1: return YES;
case 2: return NO;
default:
- self->cacheFlags.boolValue = [self->value boolValue] ? 1 : 2;
+ if (self->value == nil)
+ self->cacheFlags.boolValue = 2; /* false */
+ else
+ self->cacheFlags.boolValue = [self->value boolValue] ? 1 : 2;
return self->cacheFlags.boolValue == 1 ? YES : NO;
}
}
str = [NSMutableString stringWithCapacity:64];
[str appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
[str appendString:@" value="];
- if ([self->value isKindOfClass:[NSString class]]) {
+ if ([self->value isKindOfClass:StrClass]) {
NSString *v = self->value;
[str appendString:@"\""];
+2004-10-12 Helge Hess <helge.hess@opengroupware.org>
+
+ * v4.3.64
+
+ * Associations/WOValueAssociation.m: small tweak for bool values of nil
+
+ * SoObjects/SoObject.m: added baseURL support for appnames which end
+ with a slash
+
+ * SoObjects/SoObjectMethodDispatcher.m: do not call default methods in
+ place, but rather redirect to the method URL (can be disabled with
+ the SoRedirectToDefaultMethods default)
+
+ * SoObjects/SoObjectMethodDispatcher.m, SoObjects/SoApplication.m:
+ minor improvements to logging
+
2004-10-12 Helge Hess <helge.hess@skyrix.com>
* _WOStringTable.m: always open .strings files in ISO-Latin-1 encoding
SoPageInvocationDebugEnabled = NO;
SoProductResourceManagerDebugEnabled = NO;
SoRendererDebugEnabled = NO;
+ SoRedirectToDefaultMethods = YES;
SoSecurityManagerDebugEnabled = NO;
SoPreferredNamespacePrefixes = {
"DAV:" = "D";
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
#ifndef __NGObjWeb_DynElem_WOForm_H__
#define __NGObjWeb_DynElem_WOForm_H__
unsigned len;
id body;
- [self logWithFormat:@"parse part %@ data: %@", _part, _data];
+ [self debugWithFormat:@"parse part %@ data: %@", _part, _data];
len = [_data length];
bytes = [_data bytes];
return [body autorelease];
}
+- (BOOL)isDebuggingEnabled {
+ return NO;
+}
+
@end /* NGFormUrlBodyParser */
+
@implementation NGHttpMultipartFormDataBodyParser
+ (int)version {
}
- (BOOL)parseImmediatlyWithDelegate:(id)_delegate
- multipart:(id<NGMimePart>)_part data:(NSData *)_data {
-
+ multipart:(id<NGMimePart>)_part data:(NSData *)_data
+{
return YES;
}
hack to allow "/myapp/folder/", it is a hack because it also allows
/myapp/myapp/myapp/.../folder/ ...
*/
- if (v == nil && [self isApplicationNameLookup:_name inContext:_ctx])
+ if (v == nil && [self isApplicationNameLookup:_name inContext:_ctx]) {
v = self;
+ if (debugLookup) [self logWithFormat:@" => rewrote value: %@", self];
+ }
return v;
}
/* a) direct access, eg /MyFolder */
/* b) access via app, eg /MyApp/so/MyFolder */
[ms appendString:[rq applicationName]];
- [ms appendString:@"/"];
+ if (![ms hasSuffix:@"/"]) [ms appendString:@"/"];
/* done */
rootURL = [[ms copy] autorelease];
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
#include "SoObjectMethodDispatcher.h"
#include "SoObject.h"
@implementation SoObjectMethodDispatcher
static BOOL debugOn = NO;
+static BOOL useRedirectsForDefaultMethods = NO;
+ (void)initialize {
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
static BOOL didInit = NO;
if (didInit) return;
didInit = YES;
-
+
debugOn = [ud boolForKey:@"SoObjectMethodDispatcherDebugEnabled"];
+ useRedirectsForDefaultMethods =
+ [ud boolForKey:@"SoRedirectToDefaultMethods"];
}
- (id)initWithObject:(id)_object {
}
else if ([[self->object soClass] hasKey:[rq method] inContext:_ctx]) {
// TODO: I'm not sure whether this step is correct
- /* the class has a GET method */
+ /* the class has a GET/PUT/xxx method */
methodObject = [self->object lookupName:[rq method]
inContext:_ctx
acquire:NO];
}
+ else if (useRedirectsForDefaultMethods) {
+ /*
+ Redirect to a default method if available.
+ */
+ NSString *defaultName;
+
+ defaultName = [self->object defaultMethodNameInContext:_ctx];
+ if ([defaultName isNotNull]) {
+ if ([defaultName length] > 0) {
+ WOResponse *r;
+ NSString *url;
+
+ url = [self->object baseURLInContext:_ctx];
+ if (![url hasSuffix:@"/"]) url = [url stringByAppendingString:@"/"];
+ url = [url stringByAppendingString:defaultName];
+
+ r = [[_ctx response] retain];
+ [r setStatus:302 /* moved */];
+ [r setHeader:url forKey:@"location"];
+ [pool release];
+ return [r autorelease];
+ }
+ }
+ }
else {
- // TODO: should we replace the methodObject with a redirect to the
- // default method name? This would ensure proper URLs
+ /*
+ Note: this can lead to incorrect URLs if the base URL of the method is
+ not set (the method will run in the client URL).
+ */
methodObject = [self->object lookupDefaultMethod];
if (debugOn)
[self debugWithFormat:@"using default method: %@", methodObject];
}
/* perform call */
-
+
if (methodObject == nil || ![methodObject isCallable]) {
/*
The object is neither callable nor does it have a default method,
so we just pass it through.
+
+ Note: you can run into situations where there is a methodObject, but
+ it isn't callable. Eg this situation can occur if the default
+ method name leads to an object which isn't a method (occured in
+ the OFS context if 'index' maps to an OFSFile which itself isn't
+ callable).
*/
resultObject = self->object;
if (debugOn) {
- [self debugWithFormat:@"got no method, using object as result: %@",
- resultObject];
+ if (methodObject == nil) {
+ [self debugWithFormat:@"got no method, using object as result: %@",
+ resultObject];
+ }
+ else {
+ [self debugWithFormat:
+ @"method is not callable %@, using object as result: %@",
+ methodObject, resultObject];
+ }
}
}
else {
#if 0
/*
- if we resolve in this location, we won't be able to resolve
+ If we resolve in this location, we won't be able to resolve
application names like "Control_Panel".
+
+ TODO: explain better!
*/
if ([object respondsToSelector:@selector(rootObjectInContext:)])
object = [object rootObjectInContext:_ctx];
# version file
-SUBMINOR_VERSION:=63
+SUBMINOR_VERSION:=64
# v4.3.42 requires libNGExtensions v4.3.116
# v4.3.40 requires libNGExtensions v4.3.115