CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Thu, 24 Jul 2025 20:01:37 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20110811082516
location: https://web.archive.org/web/20110811082516/https://wiki.python.org/moin/ProxyProgramming
server-timing: captures_list;dur=23.209729, exclusion.robots;dur=0.035043, exclusion.robots.policy;dur=0.020428, esindex;dur=0.013208, cdx.remote;dur=55.915467, LoadShardBlock;dur=306.544863, PetaboxLoader3.datanode;dur=201.525904
x-app-server: wwwb-app201
x-ts: 302
x-tr: 421
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=1
set-cookie: SERVER=wwwb-app201; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Thu, 24 Jul 2025 20:01:38 GMT
content-type: text/html; charset=utf-8
x-archive-orig-date: Thu, 11 Aug 2011 08:25:16 GMT
x-archive-orig-server: Apache/2.2.16 (Debian)
x-archive-orig-vary: Cookie,User-Agent,Accept-Language
x-archive-orig-set-cookie: MOIN_SESSION_80_ROOT_moin=dbedbe634fcbce6cdb377a2f15e9631ef3e29f12; expires=Thu, 11-Aug-2011 09:25:00 GMT; Max-Age=3600; Path=/
x-archive-orig-content-length: 27949
x-archive-orig-connection: close
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
memento-datetime: Thu, 11 Aug 2011 08:25:16 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Sat, 06 May 2006 22:13:40 GMT", ; rel="prev memento"; datetime="Sat, 08 Dec 2007 10:07:24 GMT", ; rel="memento"; datetime="Thu, 11 Aug 2011 08:25:16 GMT", ; rel="next memento"; datetime="Tue, 27 Oct 2020 10:56:10 GMT", ; rel="last memento"; datetime="Sun, 04 Aug 2024 18:51:40 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: WPO-20110811071716-crawl438/WPO-20110811082112-01522.warc.gz
server-timing: captures_list;dur=0.734619, exclusion.robots;dur=0.033293, exclusion.robots.policy;dur=0.020302, esindex;dur=0.012909, cdx.remote;dur=80.741374, LoadShardBlock;dur=425.546017, PetaboxLoader3.datanode;dur=353.098821, load_resource;dur=303.888898, PetaboxLoader3.resolve;dur=184.354521
x-app-server: wwwb-app201
x-ts: 200
x-tr: 907
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=1
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
content-encoding: gzip
ProxyProgramming - PythonInfo Wiki
User
Proxy
See also https://www.python.org/workshops/1997-10/proceedings/savikko.html
special method names
pro
- ??
cons
- ??
1 # Code is Public Domain.
2 class Proxy(object):
3 def __init__(self, subject):
4 self._subject = subject
5
6 def __getattr__(self, attrName):
7 return getattr(self._subject, attrName)
8
9 def __setattr__(self, attrName, value):
10 object.__setattr__(self, attrName, value)
11
12 def __delattr__(self, attrName):
13 delattr(self._subject, attrName)
14
15 def __call__(self,*args,**keys):
16 object.__getattribute__(self,'_subject')(*args,**keys)
17
18 def __getitem__(self,key):
19 return object.__getattribute__(self,'_subject')[key]
20
21 ## should implement other special method names here
22 ## see https://www.python.org/doc/2.3.2/ref/specialnames.html
23
24 class Test:
25 def __init__(self):
26 self.toto = "toto"
27
28 def foo(self):
29 print "foo"
30
31 def __call__(self,a,b,more=False):
32 print self.__class__.__name__,id(self)
33 print a,b,more
34
35 def __getitem__(self,key):
36 return 'Test%s' % key
37
38 t = Test()
39 p = Proxy(t)
40
41 print p.toto
42 p.foo()
43 p('1',2,more=True)
44 print p['Blabla']
ProxyProgramming (last edited 2009-10-22 20:12:14 by FirstnameLastname)