Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #42811
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <dylan@dje.me> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'classes,': 0.05; 'suppose': 0.07; 'sys': 0.07; 'variables': 0.07; 'http': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; '"..."': 0.16; 'handler.': 0.16; 'new-style': 0.16; 'object):': 0.16; 'old- style': 0.16; 'subject:access': 0.16; 'subject:class': 0.16; 'wrote:': 0.18; 'solution.': 0.20; 'import': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**0': 0.24; '>': 0.26; 'first,': 0.26; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'class': 0.32; 'figure': 0.32; 'url:python': 0.33; 'skip:_ 10': 0.34; "i'd": 0.34; "can't": 0.35; 'skip:s 30': 0.35; 'something': 0.35; 'test': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'server': 0.38; 'skip:& 10': 0.38; 'skip:m 40': 0.38; 'pm,': 0.38; 'url:mail': 0.40; 'lost': 0.61; 'sample': 0.67; 'how.': 0.84 |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:x-originating-ip:in-reply-to:references :date:message-id:subject:from:to:cc:content-type:x-gm-message-state; bh=0Z8RIlEG5OvEnCSeiFlrrjKYV/dpeqovW1OExc8RaWY=; b=nRQI4fup8rCHMkkzgXM1ghkoJoifzA8UB1fDx5haJ3J8w7a7Kf4fFu/AF5UVVgT18q a3gE4hhMZ8J28mqaCudc07tZmANGCV2KLrriu4ifXDwOTq0AdmfmIYGVaESOk61xt5Yj 2L2UHbHSRNMELC6bXobNhW0jSXxCBd840cVQJilOphIJhMxMFuLRlTHoT2LUKBcIxKrf bGdFeL55IN/jPwJGQznTHWDohxW/Dl+ysDN18WR/Ref/HTobQVebe41+VgN79aQpX2o6 p+lFdR97G5KN0MKGKlCOjTmndDFDtMsftGlPLiqgstiHD9m8tvHpxgK6DDkijYibnGig 4nvw== |
| MIME-Version | 1.0 |
| X-Received | by 10.182.144.42 with SMTP id sj10mr7895804obb.66.1365164874187; Fri, 05 Apr 2013 05:27:54 -0700 (PDT) |
| X-Originating-IP | [220.245.216.139] |
| In-Reply-To | <as7paeFs5e9U1@mid.individual.net> |
| References | <as7paeFs5e9U1@mid.individual.net> |
| Date | Fri, 5 Apr 2013 22:27:54 +1000 |
| Subject | Re: HTTPserver: how to access variables of a higher class? |
| From | Dylan Evans <dylan@dje.me> |
| To | Tom P <werotizy@freent.dd> |
| Content-Type | multipart/alternative; boundary=14dae939916362e61b04d99c37b6 |
| X-Gm-Message-State | ALoCoQlNRPb6Mp4jVuq8kWWQZKIHyAvjpH3EEV+QYNgT8zFphRFE/Iy+nQtP4HGtRuX5ofDMUyP1 |
| Cc | python-list <python-list@python.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.135.1365164884.3114.python-list@python.org> (permalink) |
| Lines | 103 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1365164884 news.xs4all.nl 6937 [2001:888:2000:d::a6]:34385 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:42811 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On 05/04/2013 9:09 PM, "Tom P" <werotizy@freent.dd> wrote:
>
> First, here's a sample test program:
> <code>
> import sys
> from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
>
> class MyRequestHandler(BaseHTTPRequestHandler, object):
> def do_GET(self):
> top_self = super(MyRequestHandler, self) # try to access
MyWebServer instance
> self.send_response(200)
> self.send_header('Content-type', 'text/html')
> self.end_headers()
> self.wfile.write("thanks for trying, but I'd like to get at
self.foo and self.bar")
> return
>
> class MyWebServer(object):
> def __init__(self):
> self.foo = "foo" # these are what I want to access from inside
do_GET
> self.bar = "bar"
> self.httpd = HTTPServer(('127.0.0.1', 8000), MyRequestHandler)
> sa = self.httpd.socket.getsockname()
> print "Serving HTTP on", sa[0], "port", sa[1], "..."
>
> def runIt(self):
> self.httpd.serve_forever()
>
> server = MyWebServer()
> server.runIt()
>
> </code>
>
> I want to access the foo and bar variables from do_GET, but I can't
figure out how. I suppose this is something to do with new-style vs.
old-style classes, but I lost for a solution.
Consider inheriting HTTPServer in MyWebServer which is passed to the
request handler.
> --
> http://mail.python.org/mailman/listinfo/python-list
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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