Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
4e038901
Commit
4e038901
authored
Dec 04, 1998
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
untabified.
parent
5a85f09e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
54 deletions
+44
-54
lib/Components/ExtensionClass/ComputedAttribute.py
lib/Components/ExtensionClass/ComputedAttribute.py
+4
-14
lib/Components/ExtensionClass/test/test_Sync.py
lib/Components/ExtensionClass/test/test_Sync.py
+13
-13
lib/Components/ExtensionClass/test/test_ThreadLock.py
lib/Components/ExtensionClass/test/test_ThreadLock.py
+25
-25
lib/Components/ExtensionClass/test/test_method_hook.py
lib/Components/ExtensionClass/test/test_method_hook.py
+2
-2
No files found.
lib/Components/ExtensionClass/ComputedAttribute.py
View file @
4e038901
#!/bin/env python
##############################################################################
##############################################################################
#
#
# Copyright
# Copyright
...
@@ -77,8 +76,8 @@ called automatically, if it has one.
...
@@ -77,8 +76,8 @@ called automatically, if it has one.
This module provides a simple computed attribute implementation and
This module provides a simple computed attribute implementation and
an example of its usage.
an example of its usage.
$Id: ComputedAttribute.py,v 1.
1 1998/04/07 16:43:21
jim Exp $'''
$Id: ComputedAttribute.py,v 1.
2 1998/12/04 20:57:46
jim Exp $'''
__version__
=
'$Revision: 1.
1
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
2
$'
[
11
:
-
2
]
import
ExtensionClass
import
ExtensionClass
...
@@ -98,18 +97,9 @@ if __name__ == "__main__":
...
@@ -98,18 +97,9 @@ if __name__ == "__main__":
class
point
(
ExtensionClass
.
Base
):
class
point
(
ExtensionClass
.
Base
):
def
__init__
(
self
,
x
,
y
):
self
.
x
,
self
.
y
=
x
,
y
def
__init__
(
self
,
x
,
y
):
self
.
x
,
self
.
y
=
x
,
y
radius
=
ComputedAttribute
(
lambda
self
:
sqrt
(
self
.
x
**
2
+
self
.
y
**
2
))
radius
=
ComputedAttribute
(
lambda
self
:
sqrt
(
self
.
x
**
2
+
self
.
y
**
2
))
p
=
point
(
2
,
2
)
p
=
point
(
2
,
2
)
print
p
.
radius
print
p
.
radius
##############################################################################
#
# $Log: ComputedAttribute.py,v $
# Revision 1.1 1998/04/07 16:43:21 jim
# *** empty log message ***
#
#
lib/Components/ExtensionClass/test/test_Sync.py
View file @
4e038901
...
@@ -8,28 +8,28 @@ from time import sleep
...
@@ -8,28 +8,28 @@ from time import sleep
class
P
(
Synchronized
):
class
P
(
Synchronized
):
def
__init__
(
self
,
*
args
,
**
kw
):
def
__init__
(
self
,
*
args
,
**
kw
):
self
.
count
=
0
self
.
count
=
0
def
inc
(
self
):
def
inc
(
self
):
c
=
self
.
count
c
=
self
.
count
sleep
(
rand
()
/
327680.0
)
sleep
(
rand
()
/
327680.0
)
self
.
count
=
self
.
count
+
1
self
.
count
=
self
.
count
+
1
return
c
,
self
.
count
return
c
,
self
.
count
def
incn
(
self
,
n
):
def
incn
(
self
,
n
):
c
=
self
.
count
c
=
self
.
count
for
i
in
range
(
n
):
self
.
inc
()
for
i
in
range
(
n
):
self
.
inc
()
return
c
,
self
.
count
return
c
,
self
.
count
p
=
P
(
1
,
2
,
spam
=
3
)
p
=
P
(
1
,
2
,
spam
=
3
)
def
test
():
def
test
():
for
i
in
range
(
10
):
for
i
in
range
(
10
):
n
=
3
n
=
3
old
,
new
=
p
.
incn
(
n
)
old
,
new
=
p
.
incn
(
n
)
print
old
,
new
print
old
,
new
if
old
+
n
!=
new
:
print
'oops'
if
old
+
n
!=
new
:
print
'oops'
for
i
in
range
(
10
):
thread
.
start_new_thread
(
test
,())
for
i
in
range
(
10
):
thread
.
start_new_thread
(
test
,())
...
...
lib/Components/ExtensionClass/test/test_ThreadLock.py
View file @
4e038901
...
@@ -10,44 +10,44 @@ with_lock=1
...
@@ -10,44 +10,44 @@ with_lock=1
class
P
(
Base
):
class
P
(
Base
):
def
__oldcall_method__
(
self
,
f
,
a
,
k
=
{}):
def
__oldcall_method__
(
self
,
f
,
a
,
k
=
{}):
if
with_lock
:
if
with_lock
:
try
:
lock
=
self
.
lock
try
:
lock
=
self
.
lock
except
AttributeError
:
return
apply
(
f
,
a
,
k
)
except
AttributeError
:
return
apply
(
f
,
a
,
k
)
else
:
return
apply
(
f
,
a
,
k
)
else
:
return
apply
(
f
,
a
,
k
)
try
:
try
:
lock
.
acquire
()
lock
.
acquire
()
return
apply
(
f
,
a
,
k
)
return
apply
(
f
,
a
,
k
)
finally
:
finally
:
lock
.
release
()
lock
.
release
()
__call_method__
=
apply
__call_method__
=
apply
def
__init__
(
self
,
*
args
,
**
kw
):
def
__init__
(
self
,
*
args
,
**
kw
):
self
.
count
=
0
self
.
count
=
0
if
with_lock
:
if
with_lock
:
self
.
lock
=
lock
=
ThreadLock
.
allocate_lock
()
self
.
lock
=
lock
=
ThreadLock
.
allocate_lock
()
self
.
__call_method__
=
lock
.
guarded_apply
self
.
__call_method__
=
lock
.
guarded_apply
def
inc
(
self
):
def
inc
(
self
):
c
=
self
.
count
c
=
self
.
count
sleep
(
rand
()
/
32768.0
)
sleep
(
rand
()
/
32768.0
)
self
.
count
=
self
.
count
+
1
self
.
count
=
self
.
count
+
1
return
c
,
self
.
count
return
c
,
self
.
count
def
incn
(
self
,
n
):
def
incn
(
self
,
n
):
c
=
self
.
count
c
=
self
.
count
for
i
in
range
(
n
):
self
.
inc
()
for
i
in
range
(
n
):
self
.
inc
()
return
c
,
self
.
count
return
c
,
self
.
count
p
=
P
(
1
,
2
,
spam
=
3
)
p
=
P
(
1
,
2
,
spam
=
3
)
def
test
():
def
test
():
for
i
in
range
(
10
):
for
i
in
range
(
10
):
n
=
3
n
=
3
old
,
new
=
p
.
incn
(
n
)
old
,
new
=
p
.
incn
(
n
)
print
old
,
new
print
old
,
new
if
old
+
n
!=
new
:
print
'oops'
if
old
+
n
!=
new
:
print
'oops'
for
i
in
range
(
10
):
thread
.
start_new_thread
(
test
,())
for
i
in
range
(
10
):
thread
.
start_new_thread
(
test
,())
...
...
lib/Components/ExtensionClass/test/test_method_hook.py
View file @
4e038901
...
@@ -4,8 +4,8 @@ import ExtensionClass
...
@@ -4,8 +4,8 @@ import ExtensionClass
class
C
(
ExtensionClass
.
Base
):
class
C
(
ExtensionClass
.
Base
):
def
__call_method__
(
self
,
meth
,
args
,
kw
=
{}):
def
__call_method__
(
self
,
meth
,
args
,
kw
=
{}):
print
'give us a hook, hook, hook...'
print
'give us a hook, hook, hook...'
apply
(
meth
,
args
,
kw
)
apply
(
meth
,
args
,
kw
)
def
hi
(
self
,
*
args
,
**
kw
):
print
self
,
args
,
kw
def
hi
(
self
,
*
args
,
**
kw
):
print
self
,
args
,
kw
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment