CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Thu, 24 Jul 2025 19:45:25 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20071208100724
location: https://web.archive.org/web/20071208100724/https://wiki.python.org/moin/ProxyProgramming
server-timing: captures_list;dur=1.182102, exclusion.robots;dur=0.043988, exclusion.robots.policy;dur=0.018751, esindex;dur=0.017310, cdx.remote;dur=96.812496, LoadShardBlock;dur=97.676260, PetaboxLoader3.datanode;dur=84.012123
x-app-server: wwwb-app215
x-ts: 302
x-tr: 223
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: SERVER=wwwb-app215; 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 19:45:25 GMT
content-type: text/html;charset=utf-8
x-archive-orig-date: Sat, 08 Dec 2007 10:07:24 GMT
x-archive-orig-server: Apache/2.0.54 (Debian GNU/Linux) mod_fastcgi/2.4.2
x-archive-orig-connection: close
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
memento-datetime: Sat, 08 Dec 2007 10:07:24 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="Fri, 10 Aug 2007 07:59:51 GMT", ; rel="memento"; datetime="Sat, 08 Dec 2007 10:07:24 GMT", ; rel="next memento"; datetime="Thu, 11 Aug 2011 08:25:16 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: 52_1_20071208084132_crawl105-c/52_1_20071208100714_crawl107.arc.gz
server-timing: captures_list;dur=0.534194, exclusion.robots;dur=0.021471, exclusion.robots.policy;dur=0.009369, esindex;dur=0.012148, cdx.remote;dur=7.229336, LoadShardBlock;dur=184.317207, PetaboxLoader3.datanode;dur=203.374904, load_resource;dur=246.666759, PetaboxLoader3.resolve;dur=88.108797
x-app-server: wwwb-app215
x-ts: 200
x-tr: 497
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
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
ProxyProgramming
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 apply(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']
EditText (last edited 2003-11-17 22:51:40 by yermat)
DeleteCache (cached 2007-11-22 00:28:52)- Login
- Navigation
- Actions
- Your recent pages