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
6d8039d9
Commit
6d8039d9
authored
Sep 21, 2011
by
Patrick Gerken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Be more forgiving when trying to remove broken objects
parent
e2ee27e4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
5 deletions
+26
-5
CHANGES.txt
CHANGES.txt
+4
-1
src/zope/container/contained.py
src/zope/container/contained.py
+22
-4
No files found.
CHANGES.txt
View file @
6d8039d9
...
...
@@ -8,7 +8,10 @@ CHANGES
- Send ``IContainerModifiedEvent`` *after* the container is modified
(LP#705600).
- Preserve the original exception traceback in OrderedContainer.__setitem__.
- Preserve the original exception traceback in
OrderedContainer.__setitem__.
- Handle Broken Objects more gracefully
3.12.0 (2010-12-14)
...
...
src/zope/container/contained.py
View file @
6d8039d9
...
...
@@ -640,6 +640,19 @@ def uncontained(object, container, name=None):
>>> len(getEvents(IObjectModifiedEvent))
3
If one tries to delete a Broken object, we allow them to do
just that.
>>> class Broken(object):
... __Broken_state__ = {}
>>> broken = Broken()
>>> broken.__Broken_state__['__name__'] = u'bar'
>>> broken.__Broken_state__['__parent__'] = container
>>> container[u'bar'] = broken
>>> uncontained(broken, container, u'bar')
>>> len(getEvents(IObjectRemovedEvent))
2
"""
try
:
oldparent
=
object
.
__parent__
...
...
@@ -647,10 +660,15 @@ def uncontained(object, container, name=None):
except
AttributeError
:
# The old object doesn't implements IContained
# Maybe we're converting old data:
if
not
fixing_up
:
raise
oldparent
=
None
oldname
=
None
if
hasattr
(
object
,
'__Broken_state__'
):
state
=
object
.
__Broken_state__
oldparent
=
state
[
'__parent__'
]
oldname
=
state
[
'__name__'
]
else
:
if
not
fixing_up
:
raise
oldparent
=
None
oldname
=
None
if
oldparent
is
not
container
or
oldname
!=
name
:
if
oldparent
is
not
None
or
oldname
is
not
None
:
...
...
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