[medusa] Adding/removing handlers dynamically

Sam Rushing rushing@n...
Fri, 10 Aug 2001 20:04:57 -0700

Thomas Weholt wrote:

> I need to add/remove handlers dynamically. I got a modular web-server that
> searches a given folder for new handlers, when it finds one it would be cool
> to have it install it without restarting the server, all automatic. If I
> could build a server that search for new handlers at a given interval,
> installs all new, removes all handlers that have been removed, it would open
> for some really cool features.
> Any hints on how to implement a way of loading handlers dynamically would
> also be great.

The top-level handlers list is just that, a list. The position in the list
controls the priority of a match. You can remove handlers by calling

You could make a new kind of top-level handler that implemented your behavior -
so for example, your 'match' method would search its own list/dict/whatever for
matches under that portion of the tree. Hmm... a dictionary would probably
work pretty well. Then your top-level handler could be installed in a
'subdirectory', or perhaps as a default/fallback handler that you would install
at the end of the list.