[medusa] Re: Simple subclassing of http-server
Tue, 23 Jan 2001 21:42:36 -0300
Hi guys, I'm no Medusa expert. But I think that if what you need is to add your own handler to medusa, you need to write a new handler and then install it using start_medusa.py.
The http_server.py will then use your handler for the type of requests it should handle.
See this code (from the http_server):
it starts on line 470 (but my base code is a little bit mangled :)
for h in self.server.handlers:
if h.match (r):
self.current_request = r
I wrote a modified version of the script_handler, so I modified the start_medusa.py as follows:
scr = ec_script_handler.ec_script_handler ()
this installs my handler (ec_script_handler), so next time I start medusa, it will handle .py requests with my ec_script_handler.
Hope it helps.
PS: if you don't know how to write your own handlers, just look at the code from the other handlers ;)
On Tue, 23 Jan 2001 22:07:43 -0000, you wrote:
> I need the same thing. Have you found anything out yet?
> I seems to be one of those things where the simplest and most typical
> usage doesn't get documented. I guess I should complain since it is
> free, but I am frustrated. Is there a book out there that is
> --- In email@example.com, thomas@c... wrote:
> > I want to subclass medusas http-server-class so that I can write my
> > own request handler. The server is going to serve xml.
> > I've looked at the docs/tutorial but I cannot figure out where to
> > my own handler, so that I can pick the requested url apart, use the
> > submitted data to find what data to send back to the client.
> > The simpleHTTPServer in the standard python distro has a simpler or
> > at least more understandable approach, so if anybody could show me
> > how to get something similar to that to work with I'd be glad.
> > The only thing I need is to have a place to insert my method and
> > it return data based on the url the user typed in the browser. If I
> > can sublclass something and do it in my own subclass that would be
> > the best solution. It would be nice to leave the medusa-code alone.
> > Thanks
Nicolás Echániz | RAKAR Producciones | Buenos Aires | Argentina