Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
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
Zope
Commits
d00be8da
Commit
d00be8da
authored
Dec 05, 2005
by
Florent Guillaume
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ObjectManager now has an hasObject method to test presence. This
brings it in line with BTreeFolder.
parent
f27a9754
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
0 deletions
+37
-0
doc/CHANGES.txt
doc/CHANGES.txt
+3
-0
lib/python/OFS/ObjectManager.py
lib/python/OFS/ObjectManager.py
+14
-0
lib/python/OFS/interfaces.py
lib/python/OFS/interfaces.py
+4
-0
lib/python/OFS/tests/testObjectManager.py
lib/python/OFS/tests/testObjectManager.py
+16
-0
No files found.
doc/CHANGES.txt
View file @
d00be8da
...
...
@@ -26,6 +26,9 @@ Zope Changes
Features added
- ObjectManager now has an hasObject method to test presence. This
brings it in line with BTreeFolder.
- Using FastCGI is officially deprecated
- Improved logging of ConflictErrors. All conflict errors are
...
...
lib/python/OFS/ObjectManager.py
View file @
d00be8da
...
...
@@ -273,6 +273,20 @@ class ObjectManager(
raise
AttributeError
,
id
return
default
def
hasObject
(
self
,
id
):
"""Indicate whether the folder has an item by ID.
This doesn't try to be more intelligent than _getOb, and doesn't
consult _objects (for performance reasons). The common use case
is to check that an object does *not* exist.
"""
if
(
id
in
(
'.'
,
'..'
)
or
id
.
startswith
(
'_'
)
or
id
.
startswith
(
'aq_'
)
or
id
.
endswith
(
'__'
)):
return
False
return
getattr
(
aq_base
(
self
),
id
,
None
)
is
not
None
def
_setObject
(
self
,
id
,
object
,
roles
=
None
,
user
=
None
,
set_owner
=
1
,
suppress_events
=
False
):
"""Set an object into this container.
...
...
lib/python/OFS/interfaces.py
View file @
d00be8da
...
...
@@ -531,6 +531,10 @@ class IObjectManager(IZopeObject, ICopyContainer, INavigation, IManageable,
"""
"""
def
hasObject
(
id
):
"""Indicate whether the folder has an item by ID.
"""
def
objectIds
(
spec
=
None
):
"""List the IDs of the subobjects of the current object.
...
...
lib/python/OFS/tests/testObjectManager.py
View file @
d00be8da
...
...
@@ -328,6 +328,22 @@ class ObjectManagerTests(PlacelessSetup, unittest.TestCase):
om2
.
_setObject
(
ob
.
getId
(),
ob
)
self
.
assertRaises
(
DeleteFailed
,
om1
.
_delObject
,
'om2'
)
def
test_hasObject
(
self
):
om
=
self
.
_makeOne
()
self
.
failIf
(
om
.
hasObject
(
'_properties'
))
self
.
failIf
(
om
.
hasObject
(
'_getOb'
))
self
.
failIf
(
om
.
hasObject
(
'__of__'
))
self
.
failIf
(
om
.
hasObject
(
'.'
))
self
.
failIf
(
om
.
hasObject
(
'..'
))
self
.
failIf
(
om
.
hasObject
(
'aq_base'
))
om
.
zap__
=
True
self
.
failIf
(
om
.
hasObject
(
'zap__'
))
self
.
failIf
(
om
.
hasObject
(
'foo'
))
si
=
SimpleItem
(
'foo'
)
om
.
_setObject
(
'foo'
,
si
)
self
.
assert_
(
om
.
hasObject
(
'foo'
))
om
.
_delObject
(
'foo'
)
self
.
failIf
(
om
.
hasObject
(
'foo'
))
def
test_setObject_checkId_ok
(
self
):
om
=
self
.
_makeOne
()
...
...
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