]> err.no Git - sope/blob - sope-appserver/NGObjWeb/SoObjects/WODirectActionRequestHandler+SoObjects.m
fixed OGo bug #888
[sope] / sope-appserver / NGObjWeb / SoObjects / WODirectActionRequestHandler+SoObjects.m
1 /*
2   Copyright (C) 2000-2003 SKYRIX Software AG
3
4   This file is part of OGo
5
6   OGo is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with OGo; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21 // $Id$
22
23 #include <NGObjWeb/WODirectActionRequestHandler.h>
24 #include <NGObjWeb/WODirectAction.h>
25 #include <NGObjWeb/WOContext.h>
26 #include <NGObjWeb/WOApplication.h>
27 #include "SoObject.h"
28 #include "common.h"
29
30 @implementation WODirectActionRequestHandler(Pub)
31
32 - (id)parentObject {
33   return [WOApplication application];
34 }
35
36 - (BOOL)allowDirectActionClass:(Class)_clazz {
37 #if 0
38 #warning to be completed ...
39     if (![clazz isSubclassOfClass:[WODirectAction class]])
40       clazz = Nil;
41 #endif
42   return YES;
43 }
44
45 - (id)lookupName:(NSString *)_name inContext:(id)_ctx acquire:(BOOL)_ac {
46   Class clazz;
47   BOOL  lookupInAction = NO;
48   
49   /* check whether name is a direct-action class */
50   if ((clazz = NSClassFromString(_name))) {
51     if (![self allowDirectActionClass:clazz])
52       clazz = Nil;
53   }
54   else {
55     /* automatically use DirectAction class */
56     lookupInAction = YES;
57     clazz = NSClassFromString(@"DirectAction");
58   }
59   
60   /* found a class, construct direct action */
61   if (clazz) {
62     WODirectAction *actionObject;
63     WOContext      *ctx;
64     
65     ctx = _ctx ? _ctx : [[WOApplication application] context];
66     
67     if ((actionObject = [[clazz alloc] initWithContext:ctx]) == nil) {
68       /* failed to create object */
69       return nil;
70     }
71     actionObject = [actionObject autorelease];
72     
73     return lookupInAction
74       ? [actionObject lookupName:_name inContext:ctx acquire:_ac]
75       : actionObject;
76   }
77   
78   return [super lookupName:_name inContext:_ctx acquire:_ac];
79 }
80
81 @end /* WODirectActionRequestHandler(Pub) */