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
90363407
Commit
90363407
authored
Jul 01, 2003
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove files being moved here so we can add them on a branch.
parent
94099ace
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
0 additions
and
4360 deletions
+0
-4360
trunk/src/Persistence/PersistentList.py
trunk/src/Persistence/PersistentList.py
+0
-96
trunk/src/Persistence/PersistentMapping.py
trunk/src/Persistence/PersistentMapping.py
+0
-106
trunk/src/Persistence/cPersistence.c
trunk/src/Persistence/cPersistence.c
+0
-888
trunk/src/Persistence/cPersistence.h
trunk/src/Persistence/cPersistence.h
+0
-109
trunk/src/Persistence/cPickleCache.c
trunk/src/Persistence/cPickleCache.c
+0
-981
trunk/src/persistent/cPersistence.c
trunk/src/persistent/cPersistence.c
+0
-888
trunk/src/persistent/cPersistence.h
trunk/src/persistent/cPersistence.h
+0
-109
trunk/src/persistent/cPickleCache.c
trunk/src/persistent/cPickleCache.c
+0
-981
trunk/src/persistent/list.py
trunk/src/persistent/list.py
+0
-96
trunk/src/persistent/mapping.py
trunk/src/persistent/mapping.py
+0
-106
No files found.
trunk/src/Persistence/PersistentList.py
deleted
100644 → 0
View file @
94099ace
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
"""Python implementation of persistent list.
$Id: PersistentList.py,v 1.3 2002/08/14 22:07:09 mj Exp $"""
__version__
=
'$Revision: 1.3 $'
[
11
:
-
2
]
import
Persistence
from
UserList
import
UserList
class
PersistentList
(
UserList
,
Persistence
.
Persistent
):
__super_setitem
=
UserList
.
__setitem__
__super_delitem
=
UserList
.
__delitem__
__super_setslice
=
UserList
.
__setslice__
__super_delslice
=
UserList
.
__delslice__
__super_iadd
=
UserList
.
__iadd__
__super_imul
=
UserList
.
__imul__
__super_append
=
UserList
.
append
__super_insert
=
UserList
.
insert
__super_pop
=
UserList
.
pop
__super_remove
=
UserList
.
remove
__super_reverse
=
UserList
.
reverse
__super_sort
=
UserList
.
sort
__super_extend
=
UserList
.
extend
def
__setitem__
(
self
,
i
,
item
):
self
.
__super_setitem
(
i
,
item
)
self
.
_p_changed
=
1
def
__delitem__
(
self
,
i
):
self
.
__super_delitem
(
i
)
self
.
_p_changed
=
1
def
__setslice__
(
self
,
i
,
j
,
other
):
self
.
__super_setslice
(
i
,
j
,
other
)
self
.
_p_changed
=
1
def
__delslice__
(
self
,
i
,
j
):
self
.
__super_delslice
(
i
,
j
)
self
.
_p_changed
=
1
def
__iadd__
(
self
,
other
):
self
.
__super_iadd
(
other
)
self
.
_p_changed
=
1
def
__imul__
(
self
,
n
):
self
.
__super_imul
(
n
)
self
.
_p_changed
=
1
def
append
(
self
,
item
):
self
.
__super_append
(
item
)
self
.
_p_changed
=
1
def
insert
(
self
,
i
,
item
):
self
.
__super_insert
(
i
,
item
)
self
.
_p_changed
=
1
def
pop
(
self
,
i
=-
1
):
rtn
=
self
.
__super_pop
(
i
)
self
.
_p_changed
=
1
return
rtn
def
remove
(
self
,
item
):
self
.
__super_remove
(
item
)
self
.
_p_changed
=
1
def
reverse
(
self
):
self
.
__super_reverse
()
self
.
_p_changed
=
1
def
sort
(
self
,
*
args
):
self
.
__super_sort
(
*
args
)
self
.
_p_changed
=
1
def
extend
(
self
,
other
):
self
.
__super_extend
(
other
)
self
.
_p_changed
=
1
# This works around a bug in Python 2.1.x (up to 2.1.2 at least) where the
# __cmp__ bogusly raises a RuntimeError, and because this is an extension
# class, none of the rich comparison stuff works anyway.
def
__cmp__
(
self
,
other
):
return
cmp
(
self
.
data
,
self
.
_UserList__cast
(
other
))
trunk/src/Persistence/PersistentMapping.py
deleted
100644 → 0
View file @
94099ace
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
"""Python implementation of persistent base types
$Id: PersistentMapping.py,v 1.20 2002/08/14 22:07:09 mj Exp $"""
__version__
=
'$Revision: 1.20 $'
[
11
:
-
2
]
import
Persistence
from
UserDict
import
UserDict
class
PersistentMapping
(
UserDict
,
Persistence
.
Persistent
):
"""A persistent wrapper for mapping objects.
This class allows wrapping of mapping objects so that object
changes are registered. As a side effect, mapping objects may be
subclassed.
A subclass of PersistentMapping or any code that adds new
attributes should not create an attribute named _container. This
is reserved for backwards compatibility reasons.
"""
# UserDict provides all of the mapping behavior. The
# PersistentMapping class is responsible marking the persistent
# state as changed when a method actually changes the state. At
# the mapping API evolves, we may need to add more methods here.
__super_delitem
=
UserDict
.
__delitem__
__super_setitem
=
UserDict
.
__setitem__
__super_clear
=
UserDict
.
clear
__super_update
=
UserDict
.
update
__super_setdefault
=
UserDict
.
setdefault
def
__delitem__
(
self
,
key
):
self
.
__super_delitem
(
key
)
self
.
_p_changed
=
1
def
__setitem__
(
self
,
key
,
v
):
self
.
__super_setitem
(
key
,
v
)
self
.
_p_changed
=
1
def
clear
(
self
):
self
.
__super_clear
()
self
.
_p_changed
=
1
def
update
(
self
,
b
):
self
.
__super_update
(
b
)
self
.
_p_changed
=
1
def
setdefault
(
self
,
key
,
failobj
=
None
):
# We could inline all of UserDict's implementation into the
# method here, but I'd rather not depend at all on the
# implementation in UserDict (simple as it is).
if
not
self
.
has_key
(
key
):
self
.
_p_changed
=
1
return
self
.
__super_setdefault
(
key
,
failobj
)
try
:
__super_popitem
=
UserDict
.
popitem
except
AttributeError
:
pass
else
:
def
popitem
(
self
):
self
.
_p_changed
=
1
return
self
.
__super_popitem
()
# If the internal representation of PersistentMapping changes,
# it causes compatibility problems for pickles generated by
# different versions of the code. Compatibility works in both
# directions, because an application may want to share a database
# between applications using different versions of the code.
# Effectively, the original rep is part of the "API." To provide
# full compatibility, the getstate and setstate must read and
# right objects using the old rep.
# As a result, the PersistentMapping must save and restore the
# actual internal dictionary using the name _container.
def
__getstate__
(
self
):
state
=
{}
state
.
update
(
self
.
__dict__
)
state
[
'_container'
]
=
state
[
'data'
]
del
state
[
'data'
]
return
state
def
__setstate__
(
self
,
state
):
if
state
.
has_key
(
'_container'
):
self
.
data
=
state
[
'_container'
]
del
state
[
'_container'
]
elif
not
state
.
has_key
(
'data'
):
self
.
data
=
{}
self
.
__dict__
.
update
(
state
)
trunk/src/Persistence/cPersistence.c
deleted
100644 → 0
View file @
94099ace
This diff is collapsed.
Click to expand it.
trunk/src/Persistence/cPersistence.h
deleted
100644 → 0
View file @
94099ace
/*****************************************************************************
Copyright (c) 2001, 2002 Zope Corporation and Contributors.
All Rights Reserved.
This software is subject to the provisions of the Zope Public License,
Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
FOR A PARTICULAR PURPOSE
****************************************************************************/
#ifndef CPERSISTENCE_H
#define CPERSISTENCE_H
#include "ExtensionClass.h"
#include <time.h>
typedef
struct
CPersistentRing_struct
{
struct
CPersistentRing_struct
*
prev
;
struct
CPersistentRing_struct
*
next
;
}
CPersistentRing
;
#define CACHE_HEAD \
PyObject_HEAD \
CPersistentRing ring_home; \
int non_ghost_count;
struct
ccobject_head_struct
;
typedef
struct
ccobject_head_struct
PerCache
;
#define cPersistent_HEAD \
PyObject_HEAD \
PyObject *jar; \
PyObject *oid; \
PerCache *cache; \
CPersistentRing ring; \
char serial[8]; \
signed char state; \
unsigned char reserved[3];
#define cPersistent_GHOST_STATE -1
#define cPersistent_UPTODATE_STATE 0
#define cPersistent_CHANGED_STATE 1
#define cPersistent_STICKY_STATE 2
typedef
struct
{
cPersistent_HEAD
}
cPersistentObject
;
typedef
int
(
*
persetattr
)(
PyObject
*
,
PyObject
*
,
PyObject
*
,
setattrofunc
);
typedef
PyObject
*
(
*
pergetattr
)(
PyObject
*
,
PyObject
*
,
char
*
,
getattrofunc
);
typedef
int
(
*
percachedelfunc
)(
PerCache
*
,
PyObject
*
);
typedef
struct
{
PyMethodChain
*
methods
;
getattrofunc
getattro
;
setattrofunc
setattro
;
int
(
*
changed
)(
cPersistentObject
*
);
void
(
*
accessed
)(
cPersistentObject
*
);
void
(
*
ghostify
)(
cPersistentObject
*
);
void
(
*
deallocated
)(
cPersistentObject
*
);
int
(
*
setstate
)(
PyObject
*
);
pergetattr
pergetattro
;
persetattr
persetattro
;
percachedelfunc
percachedel
;
}
cPersistenceCAPIstruct
;
#ifndef DONT_USE_CPERSISTENCECAPI
static
cPersistenceCAPIstruct
*
cPersistenceCAPI
;
#endif
#define cPersistanceModuleName "cPersistence"
#define PERSISTENT_TYPE_FLAG EXTENSIONCLASS_USER_FLAG8
/* ExtensionClass class flags for persistent base classes should
include PERSISTENCE_FLAGS.
*/
#define PERSISTENCE_FLAGS EXTENSIONCLASS_BASICNEW_FLAG | PERSISTENT_TYPE_FLAG \
| EXTENSIONCLASS_PYTHONICATTR_FLAG
#define PER_USE_OR_RETURN(O,R) {if((O)->state==cPersistent_GHOST_STATE && cPersistenceCAPI->setstate((PyObject*)(O)) < 0) return (R); else if ((O)->state==cPersistent_UPTODATE_STATE) (O)->state=cPersistent_STICKY_STATE;}
#define PER_CHANGED(O) (cPersistenceCAPI->changed((cPersistentObject*)(O)))
#define PER_GHOSTIFY(O) (cPersistenceCAPI->ghostify((cPersistentObject*)(O)))
#define PER_ALLOW_DEACTIVATION(O) ((O)->state==cPersistent_STICKY_STATE && ((O)->state=cPersistent_UPTODATE_STATE))
#define PER_PREVENT_DEACTIVATION(O) ((O)->state==cPersistent_UPTODATE_STATE && ((O)->state=cPersistent_STICKY_STATE))
#define PER_DEL(O) (cPersistenceCAPI->deallocated((cPersistentObject*)(O)))
#define PER_USE(O) \
(((O)->state != cPersistent_GHOST_STATE \
|| (cPersistenceCAPI->setstate((PyObject*)(O)) >= 0)) \
? (((O)->state==cPersistent_UPTODATE_STATE) \
? ((O)->state=cPersistent_STICKY_STATE) : 1) : 0)
#define PER_ACCESSED(O) (cPersistenceCAPI->accessed((cPersistentObject*)(O)))
#endif
trunk/src/Persistence/cPickleCache.c
deleted
100644 → 0
View file @
94099ace
This diff is collapsed.
Click to expand it.
trunk/src/persistent/cPersistence.c
deleted
100644 → 0
View file @
94099ace
This diff is collapsed.
Click to expand it.
trunk/src/persistent/cPersistence.h
deleted
100644 → 0
View file @
94099ace
/*****************************************************************************
Copyright (c) 2001, 2002 Zope Corporation and Contributors.
All Rights Reserved.
This software is subject to the provisions of the Zope Public License,
Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
FOR A PARTICULAR PURPOSE
****************************************************************************/
#ifndef CPERSISTENCE_H
#define CPERSISTENCE_H
#include "ExtensionClass.h"
#include <time.h>
typedef
struct
CPersistentRing_struct
{
struct
CPersistentRing_struct
*
prev
;
struct
CPersistentRing_struct
*
next
;
}
CPersistentRing
;
#define CACHE_HEAD \
PyObject_HEAD \
CPersistentRing ring_home; \
int non_ghost_count;
struct
ccobject_head_struct
;
typedef
struct
ccobject_head_struct
PerCache
;
#define cPersistent_HEAD \
PyObject_HEAD \
PyObject *jar; \
PyObject *oid; \
PerCache *cache; \
CPersistentRing ring; \
char serial[8]; \
signed char state; \
unsigned char reserved[3];
#define cPersistent_GHOST_STATE -1
#define cPersistent_UPTODATE_STATE 0
#define cPersistent_CHANGED_STATE 1
#define cPersistent_STICKY_STATE 2
typedef
struct
{
cPersistent_HEAD
}
cPersistentObject
;
typedef
int
(
*
persetattr
)(
PyObject
*
,
PyObject
*
,
PyObject
*
,
setattrofunc
);
typedef
PyObject
*
(
*
pergetattr
)(
PyObject
*
,
PyObject
*
,
char
*
,
getattrofunc
);
typedef
int
(
*
percachedelfunc
)(
PerCache
*
,
PyObject
*
);
typedef
struct
{
PyMethodChain
*
methods
;
getattrofunc
getattro
;
setattrofunc
setattro
;
int
(
*
changed
)(
cPersistentObject
*
);
void
(
*
accessed
)(
cPersistentObject
*
);
void
(
*
ghostify
)(
cPersistentObject
*
);
void
(
*
deallocated
)(
cPersistentObject
*
);
int
(
*
setstate
)(
PyObject
*
);
pergetattr
pergetattro
;
persetattr
persetattro
;
percachedelfunc
percachedel
;
}
cPersistenceCAPIstruct
;
#ifndef DONT_USE_CPERSISTENCECAPI
static
cPersistenceCAPIstruct
*
cPersistenceCAPI
;
#endif
#define cPersistanceModuleName "cPersistence"
#define PERSISTENT_TYPE_FLAG EXTENSIONCLASS_USER_FLAG8
/* ExtensionClass class flags for persistent base classes should
include PERSISTENCE_FLAGS.
*/
#define PERSISTENCE_FLAGS EXTENSIONCLASS_BASICNEW_FLAG | PERSISTENT_TYPE_FLAG \
| EXTENSIONCLASS_PYTHONICATTR_FLAG
#define PER_USE_OR_RETURN(O,R) {if((O)->state==cPersistent_GHOST_STATE && cPersistenceCAPI->setstate((PyObject*)(O)) < 0) return (R); else if ((O)->state==cPersistent_UPTODATE_STATE) (O)->state=cPersistent_STICKY_STATE;}
#define PER_CHANGED(O) (cPersistenceCAPI->changed((cPersistentObject*)(O)))
#define PER_GHOSTIFY(O) (cPersistenceCAPI->ghostify((cPersistentObject*)(O)))
#define PER_ALLOW_DEACTIVATION(O) ((O)->state==cPersistent_STICKY_STATE && ((O)->state=cPersistent_UPTODATE_STATE))
#define PER_PREVENT_DEACTIVATION(O) ((O)->state==cPersistent_UPTODATE_STATE && ((O)->state=cPersistent_STICKY_STATE))
#define PER_DEL(O) (cPersistenceCAPI->deallocated((cPersistentObject*)(O)))
#define PER_USE(O) \
(((O)->state != cPersistent_GHOST_STATE \
|| (cPersistenceCAPI->setstate((PyObject*)(O)) >= 0)) \
? (((O)->state==cPersistent_UPTODATE_STATE) \
? ((O)->state=cPersistent_STICKY_STATE) : 1) : 0)
#define PER_ACCESSED(O) (cPersistenceCAPI->accessed((cPersistentObject*)(O)))
#endif
trunk/src/persistent/cPickleCache.c
deleted
100644 → 0
View file @
94099ace
This diff is collapsed.
Click to expand it.
trunk/src/persistent/list.py
deleted
100644 → 0
View file @
94099ace
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
"""Python implementation of persistent list.
$Id: list.py,v 1.3 2002/08/14 22:07:09 mj Exp $"""
__version__
=
'$Revision: 1.3 $'
[
11
:
-
2
]
import
Persistence
from
UserList
import
UserList
class
PersistentList
(
UserList
,
Persistence
.
Persistent
):
__super_setitem
=
UserList
.
__setitem__
__super_delitem
=
UserList
.
__delitem__
__super_setslice
=
UserList
.
__setslice__
__super_delslice
=
UserList
.
__delslice__
__super_iadd
=
UserList
.
__iadd__
__super_imul
=
UserList
.
__imul__
__super_append
=
UserList
.
append
__super_insert
=
UserList
.
insert
__super_pop
=
UserList
.
pop
__super_remove
=
UserList
.
remove
__super_reverse
=
UserList
.
reverse
__super_sort
=
UserList
.
sort
__super_extend
=
UserList
.
extend
def
__setitem__
(
self
,
i
,
item
):
self
.
__super_setitem
(
i
,
item
)
self
.
_p_changed
=
1
def
__delitem__
(
self
,
i
):
self
.
__super_delitem
(
i
)
self
.
_p_changed
=
1
def
__setslice__
(
self
,
i
,
j
,
other
):
self
.
__super_setslice
(
i
,
j
,
other
)
self
.
_p_changed
=
1
def
__delslice__
(
self
,
i
,
j
):
self
.
__super_delslice
(
i
,
j
)
self
.
_p_changed
=
1
def
__iadd__
(
self
,
other
):
self
.
__super_iadd
(
other
)
self
.
_p_changed
=
1
def
__imul__
(
self
,
n
):
self
.
__super_imul
(
n
)
self
.
_p_changed
=
1
def
append
(
self
,
item
):
self
.
__super_append
(
item
)
self
.
_p_changed
=
1
def
insert
(
self
,
i
,
item
):
self
.
__super_insert
(
i
,
item
)
self
.
_p_changed
=
1
def
pop
(
self
,
i
=-
1
):
rtn
=
self
.
__super_pop
(
i
)
self
.
_p_changed
=
1
return
rtn
def
remove
(
self
,
item
):
self
.
__super_remove
(
item
)
self
.
_p_changed
=
1
def
reverse
(
self
):
self
.
__super_reverse
()
self
.
_p_changed
=
1
def
sort
(
self
,
*
args
):
self
.
__super_sort
(
*
args
)
self
.
_p_changed
=
1
def
extend
(
self
,
other
):
self
.
__super_extend
(
other
)
self
.
_p_changed
=
1
# This works around a bug in Python 2.1.x (up to 2.1.2 at least) where the
# __cmp__ bogusly raises a RuntimeError, and because this is an extension
# class, none of the rich comparison stuff works anyway.
def
__cmp__
(
self
,
other
):
return
cmp
(
self
.
data
,
self
.
_UserList__cast
(
other
))
trunk/src/persistent/mapping.py
deleted
100644 → 0
View file @
94099ace
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
"""Python implementation of persistent base types
$Id: mapping.py,v 1.20 2002/08/14 22:07:09 mj Exp $"""
__version__
=
'$Revision: 1.20 $'
[
11
:
-
2
]
import
Persistence
from
UserDict
import
UserDict
class
PersistentMapping
(
UserDict
,
Persistence
.
Persistent
):
"""A persistent wrapper for mapping objects.
This class allows wrapping of mapping objects so that object
changes are registered. As a side effect, mapping objects may be
subclassed.
A subclass of PersistentMapping or any code that adds new
attributes should not create an attribute named _container. This
is reserved for backwards compatibility reasons.
"""
# UserDict provides all of the mapping behavior. The
# PersistentMapping class is responsible marking the persistent
# state as changed when a method actually changes the state. At
# the mapping API evolves, we may need to add more methods here.
__super_delitem
=
UserDict
.
__delitem__
__super_setitem
=
UserDict
.
__setitem__
__super_clear
=
UserDict
.
clear
__super_update
=
UserDict
.
update
__super_setdefault
=
UserDict
.
setdefault
def
__delitem__
(
self
,
key
):
self
.
__super_delitem
(
key
)
self
.
_p_changed
=
1
def
__setitem__
(
self
,
key
,
v
):
self
.
__super_setitem
(
key
,
v
)
self
.
_p_changed
=
1
def
clear
(
self
):
self
.
__super_clear
()
self
.
_p_changed
=
1
def
update
(
self
,
b
):
self
.
__super_update
(
b
)
self
.
_p_changed
=
1
def
setdefault
(
self
,
key
,
failobj
=
None
):
# We could inline all of UserDict's implementation into the
# method here, but I'd rather not depend at all on the
# implementation in UserDict (simple as it is).
if
not
self
.
has_key
(
key
):
self
.
_p_changed
=
1
return
self
.
__super_setdefault
(
key
,
failobj
)
try
:
__super_popitem
=
UserDict
.
popitem
except
AttributeError
:
pass
else
:
def
popitem
(
self
):
self
.
_p_changed
=
1
return
self
.
__super_popitem
()
# If the internal representation of PersistentMapping changes,
# it causes compatibility problems for pickles generated by
# different versions of the code. Compatibility works in both
# directions, because an application may want to share a database
# between applications using different versions of the code.
# Effectively, the original rep is part of the "API." To provide
# full compatibility, the getstate and setstate must read and
# right objects using the old rep.
# As a result, the PersistentMapping must save and restore the
# actual internal dictionary using the name _container.
def
__getstate__
(
self
):
state
=
{}
state
.
update
(
self
.
__dict__
)
state
[
'_container'
]
=
state
[
'data'
]
del
state
[
'data'
]
return
state
def
__setstate__
(
self
,
state
):
if
state
.
has_key
(
'_container'
):
self
.
data
=
state
[
'_container'
]
del
state
[
'_container'
]
elif
not
state
.
has_key
(
'data'
):
self
.
data
=
{}
self
.
__dict__
.
update
(
state
)
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