Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
zope-container
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
Boxiang Sun
zope-container
Commits
47b994b0
Commit
47b994b0
authored
Jun 14, 2008
by
Christophe Combelles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the previous attribute to store the btree, so that
there is a full backward compatibility
parent
c39f418b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
37 deletions
+15
-37
src/zope/app/container/btree.py
src/zope/app/container/btree.py
+15
-37
No files found.
src/zope/app/container/btree.py
View file @
47b994b0
...
...
@@ -11,12 +11,7 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""This module provides a sample container implementation.
This is primarily for testing purposes.
It might be useful as a mix-in for some classes, but many classes will
need a very different implementation.
"""This module provides a sample btree container implementation.
$Id$
"""
...
...
@@ -37,7 +32,9 @@ class BTreeContainer(Contained, Persistent):
implements
(
IBTreeContainer
)
def
__init__
(
self
):
self
.
__data
=
self
.
_newContainerData
()
# We keep the previous attribute to store the data
# for backward compatibility
self
.
_SampleContainer__data
=
self
.
_newContainerData
()
self
.
__len
=
Length
()
def
_newContainerData
(
self
):
...
...
@@ -63,12 +60,12 @@ class BTreeContainer(Contained, Persistent):
>>> "A" in c
False
'''
return
key
in
self
.
__data
return
key
in
self
.
_
SampleContainer_
_data
@
Lazy
def
_BTreeContainer__len
(
self
):
l
=
Length
()
ol
=
len
(
self
.
__data
)
ol
=
len
(
self
.
_
SampleContainer_
_data
)
if
ol
>
0
:
l
.
change
(
ol
)
self
.
_p_changed
=
True
...
...
@@ -80,19 +77,19 @@ class BTreeContainer(Contained, Persistent):
def
_setitemf
(
self
,
key
,
value
):
# make sure our lazy property gets set
l
=
self
.
__len
self
.
__data
[
key
]
=
value
self
.
_
SampleContainer_
_data
[
key
]
=
value
l
.
change
(
1
)
def
__iter__
(
self
):
return
iter
(
self
.
__data
)
return
iter
(
self
.
_
SampleContainer_
_data
)
def
__getitem__
(
self
,
key
):
'''See interface `IReadContainer`'''
return
self
.
__data
[
key
]
return
self
.
_
SampleContainer_
_data
[
key
]
def
get
(
self
,
key
,
default
=
None
):
'''See interface `IReadContainer`'''
return
self
.
__data
.
get
(
key
,
default
)
return
self
.
_
SampleContainer_
_data
.
get
(
key
,
default
)
def
__setitem__
(
self
,
key
,
value
):
setitem
(
self
,
self
.
_setitemf
,
key
,
value
)
...
...
@@ -100,39 +97,20 @@ class BTreeContainer(Contained, Persistent):
def
__delitem__
(
self
,
key
):
# make sure our lazy property gets set
l
=
self
.
__len
uncontained
(
self
.
__data
[
key
],
self
,
key
)
del
self
.
__data
[
key
]
uncontained
(
self
.
_
SampleContainer_
_data
[
key
],
self
,
key
)
del
self
.
_
SampleContainer_
_data
[
key
]
l
.
change
(
-
1
)
has_key
=
__contains__
def
items
(
self
,
key
=
None
):
return
self
.
__data
.
items
(
key
)
return
self
.
_
SampleContainer_
_data
.
items
(
key
)
def
keys
(
self
,
key
=
None
):
return
self
.
__data
.
keys
(
key
)
return
self
.
_
SampleContainer_
_data
.
keys
(
key
)
def
values
(
self
,
key
=
None
):
return
self
.
__data
.
values
(
key
)
# transparent backward compatibility
# since BTreeContainer does not inherit from SampleContainer
def
_get__data
(
self
):
try
:
return
self
.
_BTreeContainer__data
except
:
return
self
.
_SampleContainer__data
def
_set__data
(
self
,
value
):
try
:
self
.
_BTreeContainer__data
=
value
except
:
self
.
_SampleContainer__data
=
value
def
_del_data
(
self
):
try
:
del
self
.
_BTreeContainer__data
except
:
del
self
.
_SampleContainer__data
__data
=
property
(
_get__data
,
_set__data
,
_del_data
)
return
self
.
_SampleContainer__data
.
values
(
key
)
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