Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
persistent
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
persistent
Commits
a06ac75c
Commit
a06ac75c
authored
Jun 28, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Full unit test coverage for p.wref.
Fixed a typo in PWRD.update found by coverage.
parent
e6ec2ba6
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
239 additions
and
51 deletions
+239
-51
persistent/tests/test_wref.py
persistent/tests/test_wref.py
+232
-46
persistent/wref.py
persistent/wref.py
+7
-5
No files found.
persistent/tests/test_wref.py
View file @
a06ac75c
This diff is collapsed.
Click to expand it.
persistent/wref.py
View file @
a06ac75c
...
...
@@ -53,6 +53,8 @@ class WeakRef(object):
return
hash
(
self
)
def
__eq__
(
self
,
other
):
if
not
isinstance
(
other
,
WeakRef
):
return
False
self
=
self
()
if
self
is
None
:
raise
TypeError
(
'Weakly-referenced object has gone away'
)
...
...
@@ -73,15 +75,15 @@ class PersistentWeakKeyDictionary(Persistent):
# It would be helpful if the data manager/connection cached these.
def
__init__
(
self
,
adict
=
None
,
**
kwargs
):
# XXX 'kwargs' is pointles, because keys must be strings, but we
# are going to try (and fail) to wrap a WeakRef around them.
self
.
data
=
{}
if
adict
is
not
None
:
keys
=
getattr
(
adict
,
"keys"
,
None
)
if
keys
is
None
:
adict
=
dict
(
adict
)
self
.
update
(
adict
)
if
kwargs
:
# XXX 'kwargs' is pointless, because keys must be strings, but we
# are going to try (and fail) to wrap a WeakRef around them.
if
kwargs
:
#pragma NO COVER
self
.
update
(
kwargs
)
def
__getstate__
(
self
):
...
...
@@ -119,9 +121,9 @@ class PersistentWeakKeyDictionary(Persistent):
def
update
(
self
,
adict
):
if
isinstance
(
adict
,
PersistentWeakKeyDictionary
):
self
.
data
.
update
(
adict
.
update
)
self
.
data
.
update
(
adict
.
data
)
else
:
for
k
,
v
in
adict
.
items
():
self
.
data
[
WeakRef
(
k
)]
=
v
# TODO: May need more methods
,
and tests.
# TODO: May need more methods and tests.
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