On Tue, 2003-07-29 at 04:36, [EMAIL PROTECTED] wrote: > I know that this is "done and dusted" already, but I also think that this is > a great idea. You may have seen a patch I submitted which attempts to allow > Webware contexts to have "virtual resources" in much the same way that > mod_python doesn't care what the requested resource is called as long as the > extension is the one mapped to the specified mod_python handler. My patch > does an inelegant workaround with respect to caching, and it also has to > suppress the insistence that real files exist for every requested resource - > something which certainly is useful in many situations (eg. checking > modified times against active servlets), but is obstructive or unnecessary > in other situations (eg. "virtual resources").
This actually doesn't handle virtual resources. Unlike mod_python, URLParser adds the extension itself, so it has to have a filesystem to search. The assumption of a file is carried on into ServletFactory, at least into the caching that is performed. If you want to use virtual resources you'd have to put a sub-parser in the path somewhere (probably in an __init__.py file), like: class SubParser(URLParser): def __init__(self, rootObj): self.rootObj = rootObj def parse(self, trans, requestPath): # URLParser needs a helper function here... splitted = requestPath[1:].split('/', 1) first = splitted[0] if splitted[1:]: rest = '/' + splitted[1:] else: rest = '' # now we get to do interesting things... if first.startswith('_'): # More access controls are probably called for raise HTTPForbidden dest = getattr(self.rootObj, first) if rest: return SubParser(dest).parse(self, trans, rest) else: return dest Hmm... that's assuming you are traversing a bunch of threadsafe servlet-like objects, which is an unlikely scenario. The factory only comes in indirectly, by changing that last line -- in a more likely case you'd probably be wrapping the final object in a servlet class. Which is what a factory does... I don't know, it's not all thought out yet. Ian ------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 _______________________________________________ Webware-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/webware-devel