Commit a84477cc authored by Jim Fulton's avatar Jim Fulton

*** empty log message ***

parent 656beed4
......@@ -53,8 +53,8 @@ Acquisition
cannot be found in 'a'.
Aquisition wrappers provide access to the wrapped objects
through the attributes 'aq_parent' and 'aq_self'. In the
example above, the expressions::
through the attributes 'aq_parent', 'aq_self', 'aq_base'.
In the example above, the expressions::
'c.a.aq_parent is c'
......@@ -69,6 +69,10 @@ Acquisition
evaluates to false, because the expression 'c.a' evaluates
to an acquisition wrapper around 'c' and 'a', not 'a' itself.
The attribute 'aq_base' is similar to 'aq_self'. Wrappers may be
nested and 'aq_self' may be a wrapped object. The 'aq_base'
attribute is the underlying object with all wrappers removed.
Acquisition Control
Two styles of acquisition are supported in the current
......
ExtensionClass.stx
ExtensionClass.html
Installation
Installation.html
Acquisition.stx
Acquisition.html
MultiMapping.stx
MultiMapping.html
release.notes
release.html
README
Makefile.pre.in
Makefile.pre.in-1.4
Makefile.pre.in-1.5
Setup
ExtensionClass.c
ExtensionClass.h
......
......@@ -6,5 +6,8 @@ M=ExtensionClass
StructuredText < $M.stx > $M.html
rm -rf "$M-$R"
mkdir "$M-$R"
tar -c -R release.fl -f - | (cd "$M-$R"; tar xvf -)
for f in `cat release.fl`; do
cp $f "$M-$R/"
done
tar cvf - "$M-$R" | gzip > "$M-$R.tar.gz"
from MultiMapping import *
m=MultiMapping()
m.push({'spam':1, 'eggs':2})
print m['spam']
print m['eggs']
m.push({'spam':3})
print m['spam']
print m['eggs']
print m.pop()
print m.pop()
try:
print m.pop()
raise "That\'s odd", "This last pop should have failed!"
except: # I should probably raise a specific error in this case.
pass
from Sync import Synchronized
import thread
from rand import rand
from time import sleep
class P(Synchronized):
def __init__(self,*args,**kw):
self.count=0
def inc(self):
c=self.count
sleep(rand()/327680.0)
self.count=self.count+1
return c,self.count
def incn(self,n):
c=self.count
for i in range(n): self.inc()
return c,self.count
p=P(1,2,spam=3)
def test():
for i in range(10):
n=3
old,new=p.incn(n)
print old,new
if old+n != new: print 'oops'
for i in range(10): thread.start_new_thread(test,())
sleep(50)
import ThreadLock, thread
from rand import rand
from time import sleep
from ExtensionClass import Base
with_lock=1
class P(Base):
def __oldcall_method__(self,f,a,k={}):
if with_lock:
try: lock=self.lock
except AttributeError: return apply(f,a,k)
else: return apply(f,a,k)
try:
lock.acquire()
return apply(f,a,k)
finally:
lock.release()
__call_method__=apply
def __init__(self,*args,**kw):
self.count=0
if with_lock:
self.lock=lock=ThreadLock.allocate_lock()
self.__call_method__=lock.guarded_apply
def inc(self):
c=self.count
sleep(rand()/32768.0)
self.count=self.count+1
return c,self.count
def incn(self,n):
c=self.count
for i in range(n): self.inc()
return c,self.count
p=P(1,2,spam=3)
def test():
for i in range(10):
n=3
old,new=p.incn(n)
print old,new
if old+n != new: print 'oops'
for i in range(10): thread.start_new_thread(test,())
sleep(50)
from ExtensionClass import Base
import Acquisition
class B(Base):
color='red'
class A(Acquisition.Implicit):
def hi(self): print self, self.color
b=B()
b.a=A()
b.a.hi()
b.a.color='green'
b.a.hi()
try:
A().hi()
raise 'Program error', 'spam'
except AttributeError: pass
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment