[Zope-Checkins] SVN: Zope/trunk/src/OFS/ - fixed handling of unicode ids
Yvo Schubbe
cvs-admin at zope.org
Fri Jul 20 14:11:07 UTC 2012
Log message for revision 127356:
- fixed handling of unicode ids
- related cleanup
Changed:
U Zope/trunk/src/OFS/ObjectManager.py
U Zope/trunk/src/OFS/tests/testObjectManager.py
-=-
Modified: Zope/trunk/src/OFS/ObjectManager.py
===================================================================
--- Zope/trunk/src/OFS/ObjectManager.py 2012-07-20 08:32:03 UTC (rev 127355)
+++ Zope/trunk/src/OFS/ObjectManager.py 2012-07-20 14:11:03 UTC (rev 127356)
@@ -501,34 +501,36 @@
The objects specified in 'ids' get deleted.
"""
- if type(ids) is type(''): ids=[ids]
+ if isinstance(ids, basestring):
+ ids = [ids]
if not ids:
return MessageDialog(title='No items specified',
message='No items were specified!',
- action ='./manage_main',)
- try: p=self._reserved_names
- except: p=()
+ action='./manage_main',)
+ try:
+ p = self._reserved_names
+ except:
+ p = ()
for n in ids:
if n in p:
return MessageDialog(title='Not Deletable',
message='<EM>%s</EM> cannot be deleted.' % escape(n),
- action ='./manage_main',)
+ action='./manage_main',)
while ids:
- id=ids[-1]
- v=self._getOb(id, self)
+ id = ids[-1]
+ v = self._getOb(id, self)
if v.wl_isLocked():
- raise ResourceLockedError, (
+ raise ResourceLockedError(
'Object "%s" is locked via WebDAV' % v.getId())
if v is self:
- raise BadRequest, '%s does not exist' % escape(ids[-1])
+ raise BadRequest('%s does not exist' % escape(ids[-1]))
self._delObject(id)
del ids[-1]
if REQUEST is not None:
return self.manage_main(self, REQUEST, update_menu=1)
-
def tpValues(self):
# Return a list of subobjects, used by tree tag.
r=[]
Modified: Zope/trunk/src/OFS/tests/testObjectManager.py
===================================================================
--- Zope/trunk/src/OFS/tests/testObjectManager.py 2012-07-20 08:32:03 UTC (rev 127355)
+++ Zope/trunk/src/OFS/tests/testObjectManager.py 2012-07-20 14:11:03 UTC (rev 127356)
@@ -6,7 +6,6 @@
from AccessControl.SecurityManager import setSecurityPolicy
from AccessControl.SpecialUsers import emergency_user, nobody, system
from AccessControl.User import User # before SpecialUsers
-from Acquisition import aq_base
from Acquisition import Implicit
from App.config import getConfiguration
from logging import getLogger
@@ -258,7 +257,7 @@
om._delObject(ob.getId())
finally:
logger.disabled = 0
-
+
def test_delObject_exception_debug_manager(self):
# Test exception behavior in manage_beforeDelete in debug mode
# Manager user
@@ -303,6 +302,21 @@
finally:
logger.disabled = 0
+ def test_manage_delObjects(self):
+ om = self._makeOne()
+ ob = ItemForDeletion()
+ om._setObject('stuff', ob)
+ om.manage_delObjects('stuff')
+ self.assertFalse('stuff' in om)
+
+ om._setObject('stuff', ob)
+ om.manage_delObjects(['stuff'])
+ self.assertFalse('stuff' in om)
+
+ om._setObject('stuff', ob)
+ om.manage_delObjects(u'stuff')
+ self.assertFalse('stuff' in om)
+
def test_hasObject(self):
om = self._makeOne()
self.assertFalse(om.hasObject('_properties'))
More information about the Zope-Checkins
mailing list