Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #42953

Re: The SOLUTION HTTPserver: how to access variables of a higher class

From Tom P <werotizy@freent.dd>
Newsgroups comp.lang.python
Subject Re: The SOLUTION HTTPserver: how to access variables of a higher class
Date 2013-04-06 23:38 +0200
Message-ID <asbiuiFo2c5U1@mid.individual.net> (permalink)
References <as7paeFs5e9U1@mid.individual.net>

Show all headers | View raw


On 04/05/2013 01:02 PM, Tom P wrote:

ok, after much experimenting it looks like the solution is as follows:

class MyWebServer(object):
     def __init__(self):
   #      self.foo = "foo"  delete these from self
    #     self.bar = "bar"
         myServer = HTTPServer
         myServer.foo = "foo"  #define foo,bar here
         myServer.bar = "bar"

         self.httpd = myServer(('127.0.0.1', 8000), MyRequestHandler)

Then, in the request handler:
class MyRequestHandler(BaseHTTPRequestHandler):
     def do_GET(self):
         ss=self.server
         print ss.foo

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

HTTPserver: how to access variables of a higher class? Tom P <werotizy@freent.dd> - 2013-04-05 13:02 +0200
  Re: HTTPserver: how to access variables of a higher class? Dave Angel <davea@davea.name> - 2013-04-05 07:54 -0400
    Re: HTTPserver: how to access variables of a higher class? Tom P <werotizy@freent.dd> - 2013-04-05 15:26 +0200
    Re: HTTPserver: how to access variables of a higher class? Tom P <werotizy@freent.dd> - 2013-04-05 23:41 +0200
      Re: HTTPserver: how to access variables of a higher class? Dave Angel <davea@davea.name> - 2013-04-05 23:19 -0400
  Re: HTTPserver: how to access variables of a higher class? Dylan Evans <dylan@dje.me> - 2013-04-05 22:27 +1000
    Re: HTTPserver: how to access variables of a higher class? Tom P <werotizy@freent.dd> - 2013-04-05 15:21 +0200
    Re: HTTPserver: how to access variables of a higher class? Tom P <werotizy@freent.dd> - 2013-04-06 17:05 +0200
      Re: HTTPserver: how to access variables of a higher class? Dylan Evans <dylan@dje.me> - 2013-04-07 11:51 +1000
  Re: The SOLUTION HTTPserver: how to access variables of a higher class Tom P <werotizy@freent.dd> - 2013-04-06 23:38 +0200

csiph-web