Is it possible to create dynamic HTTP Handlers?

184 views Asked by At

I've browsed through a ton of the material here at Stackoverflow and you've all done an amazing job of answering all the questions I've had. However, I am currently writing my own handlers for my HTTPS servers and I was wondering if there are a way to instantiate the handlers dynamically. Currently I have to pass the class itself to the server to create the server. This means that the global variable of the version will be the same for all. The solution would be to write handlers for each of the servers since they all share the same handler except for the server version name and GET methods. Here is my question:

Is there a way to dynamically create the handlers and pass them? I've tried to wrap the handler class in another class like so:

class Virtual_Handler(object):

    class Virtual_Service_Handler(BaseHTTPServer.BaseHTTPRequestHandler)
        #normal handler stuff

Of course there are a couple variables I am passing to each handler to make them different such as the get method, etc. At any rate when I create an pool of handlers in this fashion:

for i in range(3):
    handlers[i] = Virtual_Handler()

All of the

handlers[i].Virtual_Service_Handler

point to the same memory address. Which means that they are the same instance of the object. Is there something I am missing? Is it not possible to create the handler dynamically even after wrapping it in another class?

0

There are 0 answers