Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZODB
Commits
fe2e7481
Commit
fe2e7481
authored
Nov 28, 2001
by
Chris McDonough
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backed out changes to PersistentMapping that happened on Standalone ZODB branch.
parent
686994a0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
180 additions
and
105 deletions
+180
-105
trunk/src/Persistence/PersistentMapping.py
trunk/src/Persistence/PersistentMapping.py
+60
-35
trunk/src/ZODB/PersistentMapping.py
trunk/src/ZODB/PersistentMapping.py
+60
-35
trunk/src/persistent/mapping.py
trunk/src/persistent/mapping.py
+60
-35
No files found.
trunk/src/Persistence/PersistentMapping.py
View file @
fe2e7481
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
...
@@ -13,54 +13,79 @@
...
@@ -13,54 +13,79 @@
__doc__
=
'''Python implementation of persistent base types
__doc__
=
'''Python implementation of persistent base types
$Id: PersistentMapping.py,v 1.1
4 2001/11/28 15:51:20 matt
Exp $'''
$Id: PersistentMapping.py,v 1.1
5 2001/11/28 22:20:11 chrism
Exp $'''
__version__
=
'$Revision: 1.1
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
5
$'
[
11
:
-
2
]
import
Persistence
import
Persistence
import
types
import
types
from
UserDict
import
UserDict
_marker
=
[]
_marker
=
[]
class
PersistentMapping
(
Persistence
.
Persistent
):
class
PersistentMapping
(
UserDict
,
Persistence
.
Persistent
):
"""A persistent wrapper for mapping objects.
"""A persistent wrapper for mapping objects.
This class allows wrapping of mapping objects so that
object
This class allows wrapping of mapping objects so that
changes are registered. As a side effect, mapping objects may be
object changes are registered. As a side effect,
subclassed.
mapping objects may be
subclassed.
"""
"""
__super_delitem
=
UserDict
.
__delitem__
def
__init__
(
self
,
container
=
None
):
__super_setitem
=
UserDict
.
__setitem__
if
container
is
None
:
container
=
{}
__super_clear
=
UserDict
.
clear
self
.
_container
=
container
__super_update
=
UserDict
.
update
__super_setdefault
=
UserDict
.
setdefault
__super_popitem
=
UserDict
.
popitem
def
__delitem__
(
self
,
key
):
def
__delitem__
(
self
,
key
):
self
.
__super_delitem
(
key
)
del
self
.
_container
[
key
]
self
.
_p_changed
=
1
try
:
del
self
.
_v_keys
except
:
pass
self
.
__changed__
(
1
)
def
__getitem__
(
self
,
key
):
return
self
.
_container
[
key
]
def
__len__
(
self
):
return
len
(
self
.
_container
)
def
__setitem__
(
self
,
key
,
v
):
def
__setitem__
(
self
,
key
,
v
):
self
.
__super_setitem
(
key
,
v
)
self
.
_container
[
key
]
=
v
self
.
_p_changed
=
1
try
:
del
self
.
_v_keys
except
:
pass
self
.
__changed__
(
1
)
def
clear
(
self
):
def
clear
(
self
):
self
.
__super_clear
()
self
.
_container
.
clear
()
self
.
_p_changed
=
1
self
.
_p_changed
=
1
if
hasattr
(
self
,
'_v_keys'
):
del
self
.
_v_keys
def
copy
(
self
):
return
self
.
__class__
(
self
.
_container
.
copy
())
def
get
(
self
,
key
,
default
=
_marker
):
if
default
is
_marker
:
return
self
.
_container
.
get
(
key
)
else
:
return
self
.
_container
.
get
(
key
,
default
)
def
has_key
(
self
,
key
):
return
self
.
_container
.
has_key
(
key
)
def
items
(
self
):
return
map
(
lambda
k
,
d
=
self
:
(
k
,
d
[
k
]),
self
.
keys
())
def
keys
(
self
):
try
:
return
list
(
self
.
_v_keys
)
# return a copy (Collector 2283)
except
:
pass
keys
=
self
.
_v_keys
=
filter
(
lambda
k
:
not
isinstance
(
k
,
types
.
StringType
)
or
k
[:
1
]
!=
'_'
,
self
.
_container
.
keys
())
keys
.
sort
()
return
list
(
keys
)
def
update
(
self
,
b
):
def
update
(
self
,
b
):
self
.
__super_update
(
b
)
a
=
self
.
_container
self
.
_p_changed
=
1
for
k
,
v
in
b
.
items
():
a
[
k
]
=
v
try
:
del
self
.
_v_keys
def
setdefault
(
self
,
key
,
failobj
=
None
):
except
:
pass
# We could inline all of UserDict's implementation into the
self
.
_p_changed
=
1
# method here, but I'd rather not depend at all on the
# implementation in UserDict (simple as it is).
def
values
(
self
):
if
not
self
.
has_key
(
key
):
return
map
(
lambda
k
,
d
=
self
:
d
[
k
],
self
.
keys
())
self
.
_p_changed
=
1
return
self
.
__super_setdefault
(
key
,
failobj
)
def
__cmp__
(
self
,
other
):
return
cmp
(
self
.
_container
,
other
.
_container
)
def
popitem
(
self
):
self
.
_p_changed
=
1
return
self
.
__super_popitem
()
trunk/src/ZODB/PersistentMapping.py
View file @
fe2e7481
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
...
@@ -13,54 +13,79 @@
...
@@ -13,54 +13,79 @@
__doc__
=
'''Python implementation of persistent base types
__doc__
=
'''Python implementation of persistent base types
$Id: PersistentMapping.py,v 1.1
4 2001/11/28 15:51:20 matt
Exp $'''
$Id: PersistentMapping.py,v 1.1
5 2001/11/28 22:20:11 chrism
Exp $'''
__version__
=
'$Revision: 1.1
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
5
$'
[
11
:
-
2
]
import
Persistence
import
Persistence
import
types
import
types
from
UserDict
import
UserDict
_marker
=
[]
_marker
=
[]
class
PersistentMapping
(
Persistence
.
Persistent
):
class
PersistentMapping
(
UserDict
,
Persistence
.
Persistent
):
"""A persistent wrapper for mapping objects.
"""A persistent wrapper for mapping objects.
This class allows wrapping of mapping objects so that
object
This class allows wrapping of mapping objects so that
changes are registered. As a side effect, mapping objects may be
object changes are registered. As a side effect,
subclassed.
mapping objects may be
subclassed.
"""
"""
__super_delitem
=
UserDict
.
__delitem__
def
__init__
(
self
,
container
=
None
):
__super_setitem
=
UserDict
.
__setitem__
if
container
is
None
:
container
=
{}
__super_clear
=
UserDict
.
clear
self
.
_container
=
container
__super_update
=
UserDict
.
update
__super_setdefault
=
UserDict
.
setdefault
__super_popitem
=
UserDict
.
popitem
def
__delitem__
(
self
,
key
):
def
__delitem__
(
self
,
key
):
self
.
__super_delitem
(
key
)
del
self
.
_container
[
key
]
self
.
_p_changed
=
1
try
:
del
self
.
_v_keys
except
:
pass
self
.
__changed__
(
1
)
def
__getitem__
(
self
,
key
):
return
self
.
_container
[
key
]
def
__len__
(
self
):
return
len
(
self
.
_container
)
def
__setitem__
(
self
,
key
,
v
):
def
__setitem__
(
self
,
key
,
v
):
self
.
__super_setitem
(
key
,
v
)
self
.
_container
[
key
]
=
v
self
.
_p_changed
=
1
try
:
del
self
.
_v_keys
except
:
pass
self
.
__changed__
(
1
)
def
clear
(
self
):
def
clear
(
self
):
self
.
__super_clear
()
self
.
_container
.
clear
()
self
.
_p_changed
=
1
self
.
_p_changed
=
1
if
hasattr
(
self
,
'_v_keys'
):
del
self
.
_v_keys
def
copy
(
self
):
return
self
.
__class__
(
self
.
_container
.
copy
())
def
get
(
self
,
key
,
default
=
_marker
):
if
default
is
_marker
:
return
self
.
_container
.
get
(
key
)
else
:
return
self
.
_container
.
get
(
key
,
default
)
def
has_key
(
self
,
key
):
return
self
.
_container
.
has_key
(
key
)
def
items
(
self
):
return
map
(
lambda
k
,
d
=
self
:
(
k
,
d
[
k
]),
self
.
keys
())
def
keys
(
self
):
try
:
return
list
(
self
.
_v_keys
)
# return a copy (Collector 2283)
except
:
pass
keys
=
self
.
_v_keys
=
filter
(
lambda
k
:
not
isinstance
(
k
,
types
.
StringType
)
or
k
[:
1
]
!=
'_'
,
self
.
_container
.
keys
())
keys
.
sort
()
return
list
(
keys
)
def
update
(
self
,
b
):
def
update
(
self
,
b
):
self
.
__super_update
(
b
)
a
=
self
.
_container
self
.
_p_changed
=
1
for
k
,
v
in
b
.
items
():
a
[
k
]
=
v
try
:
del
self
.
_v_keys
def
setdefault
(
self
,
key
,
failobj
=
None
):
except
:
pass
# We could inline all of UserDict's implementation into the
self
.
_p_changed
=
1
# method here, but I'd rather not depend at all on the
# implementation in UserDict (simple as it is).
def
values
(
self
):
if
not
self
.
has_key
(
key
):
return
map
(
lambda
k
,
d
=
self
:
d
[
k
],
self
.
keys
())
self
.
_p_changed
=
1
return
self
.
__super_setdefault
(
key
,
failobj
)
def
__cmp__
(
self
,
other
):
return
cmp
(
self
.
_container
,
other
.
_container
)
def
popitem
(
self
):
self
.
_p_changed
=
1
return
self
.
__super_popitem
()
trunk/src/persistent/mapping.py
View file @
fe2e7481
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
...
@@ -13,54 +13,79 @@
...
@@ -13,54 +13,79 @@
__doc__
=
'''Python implementation of persistent base types
__doc__
=
'''Python implementation of persistent base types
$Id: mapping.py,v 1.1
4 2001/11/28 15:51:20 matt
Exp $'''
$Id: mapping.py,v 1.1
5 2001/11/28 22:20:11 chrism
Exp $'''
__version__
=
'$Revision: 1.1
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
5
$'
[
11
:
-
2
]
import
Persistence
import
Persistence
import
types
import
types
from
UserDict
import
UserDict
_marker
=
[]
_marker
=
[]
class
PersistentMapping
(
Persistence
.
Persistent
):
class
PersistentMapping
(
UserDict
,
Persistence
.
Persistent
):
"""A persistent wrapper for mapping objects.
"""A persistent wrapper for mapping objects.
This class allows wrapping of mapping objects so that
object
This class allows wrapping of mapping objects so that
changes are registered. As a side effect, mapping objects may be
object changes are registered. As a side effect,
subclassed.
mapping objects may be
subclassed.
"""
"""
__super_delitem
=
UserDict
.
__delitem__
def
__init__
(
self
,
container
=
None
):
__super_setitem
=
UserDict
.
__setitem__
if
container
is
None
:
container
=
{}
__super_clear
=
UserDict
.
clear
self
.
_container
=
container
__super_update
=
UserDict
.
update
__super_setdefault
=
UserDict
.
setdefault
__super_popitem
=
UserDict
.
popitem
def
__delitem__
(
self
,
key
):
def
__delitem__
(
self
,
key
):
self
.
__super_delitem
(
key
)
del
self
.
_container
[
key
]
self
.
_p_changed
=
1
try
:
del
self
.
_v_keys
except
:
pass
self
.
__changed__
(
1
)
def
__getitem__
(
self
,
key
):
return
self
.
_container
[
key
]
def
__len__
(
self
):
return
len
(
self
.
_container
)
def
__setitem__
(
self
,
key
,
v
):
def
__setitem__
(
self
,
key
,
v
):
self
.
__super_setitem
(
key
,
v
)
self
.
_container
[
key
]
=
v
self
.
_p_changed
=
1
try
:
del
self
.
_v_keys
except
:
pass
self
.
__changed__
(
1
)
def
clear
(
self
):
def
clear
(
self
):
self
.
__super_clear
()
self
.
_container
.
clear
()
self
.
_p_changed
=
1
self
.
_p_changed
=
1
if
hasattr
(
self
,
'_v_keys'
):
del
self
.
_v_keys
def
copy
(
self
):
return
self
.
__class__
(
self
.
_container
.
copy
())
def
get
(
self
,
key
,
default
=
_marker
):
if
default
is
_marker
:
return
self
.
_container
.
get
(
key
)
else
:
return
self
.
_container
.
get
(
key
,
default
)
def
has_key
(
self
,
key
):
return
self
.
_container
.
has_key
(
key
)
def
items
(
self
):
return
map
(
lambda
k
,
d
=
self
:
(
k
,
d
[
k
]),
self
.
keys
())
def
keys
(
self
):
try
:
return
list
(
self
.
_v_keys
)
# return a copy (Collector 2283)
except
:
pass
keys
=
self
.
_v_keys
=
filter
(
lambda
k
:
not
isinstance
(
k
,
types
.
StringType
)
or
k
[:
1
]
!=
'_'
,
self
.
_container
.
keys
())
keys
.
sort
()
return
list
(
keys
)
def
update
(
self
,
b
):
def
update
(
self
,
b
):
self
.
__super_update
(
b
)
a
=
self
.
_container
self
.
_p_changed
=
1
for
k
,
v
in
b
.
items
():
a
[
k
]
=
v
try
:
del
self
.
_v_keys
def
setdefault
(
self
,
key
,
failobj
=
None
):
except
:
pass
# We could inline all of UserDict's implementation into the
self
.
_p_changed
=
1
# method here, but I'd rather not depend at all on the
# implementation in UserDict (simple as it is).
def
values
(
self
):
if
not
self
.
has_key
(
key
):
return
map
(
lambda
k
,
d
=
self
:
d
[
k
],
self
.
keys
())
self
.
_p_changed
=
1
return
self
.
__super_setdefault
(
key
,
failobj
)
def
__cmp__
(
self
,
other
):
return
cmp
(
self
.
_container
,
other
.
_container
)
def
popitem
(
self
):
self
.
_p_changed
=
1
return
self
.
__super_popitem
()
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