Commit 4412eb89 authored by 's avatar

Fixed bug that required objects to have a __len__ when a specifier was

given to objectValues, Ids, and Items.
parent 33eb7c50
__doc__="""Object Manager __doc__="""Object Manager
$Id: ObjectManager.py,v 1.36 1998/03/09 19:58:20 jim Exp $""" $Id: ObjectManager.py,v 1.37 1998/03/18 17:54:29 brian Exp $"""
__version__='$Revision: 1.36 $'[11:-2] __version__='$Revision: 1.37 $'[11:-2]
import Persistence, App.Management, Acquisition, App.Undo, Globals import Persistence, App.Management, Acquisition, App.Undo, Globals
from Globals import HTMLFile, HTMLFile from Globals import HTMLFile, HTMLFile
...@@ -111,32 +111,39 @@ class ObjectManager( ...@@ -111,32 +111,39 @@ class ObjectManager(
delattr(self,id) delattr(self,id)
self._objects=tuple(filter(lambda i,n=id: i['id']!=n, self._objects)) self._objects=tuple(filter(lambda i,n=id: i['id']!=n, self._objects))
def objectIds(self,t=None): def objectIds(self, spec=None):
# Return a list of subobject ids # Return a list of subobject ids
if t is not None: if spec is not None:
if type(t)==type('s'): t=(t,) if type(spec)==type('s'):
return filter(None, map(lambda x,v=t: spec=[spec]
(x['meta_type'] in v) and x['id'] or None, set=[]
self._objects)) for ob in self._objects:
if ob['meta_type'] in spec:
set.append(ob['id'])
return set
return map(lambda i: i['id'], self._objects) return map(lambda i: i['id'], self._objects)
def objectValues(self,t=None): def objectValues(self, spec=None):
# Return a list of the actual subobjects # Return a list of the actual subobjects
if t is not None: if spec is not None:
if type(t)==type('s'): t=(t,) if type(spec)==type('s'):
return filter(None, map(lambda x,v=t,s=self: spec=[spec]
(x['meta_type'] in v) and getattr(s,x['id']) or None, set=[]
self._objects)) for ob in self._objects:
if ob['meta_type'] in spec:
set.append(getattr(self, ob['id']))
return set
return map(lambda i,s=self: getattr(s,i['id']), self._objects) return map(lambda i,s=self: getattr(s,i['id']), self._objects)
def objectItems(self,t=None): def objectItems(self, spec=None):
# Return a list of (id, subobject) tuples # Return a list of (id, subobject) tuples
if t is not None: if spec is not None:
if type(t)==type('s'): t=(t,) if type(spec)==type('s'):
return filter(None, map(lambda x,v=t,s=self: spec=[spec]
(x['meta_type'] in v) and \ set=[]
(x['id'],getattr(s,x['id'])) or None, for ob in self._objects:
self._objects)) if ob['meta_type'] in spec:
set.append((ob['id'], getattr(self, ob['id'])))
return map(lambda i,s=self: (i['id'], getattr(s,i['id'])), return map(lambda i,s=self: (i['id'], getattr(s,i['id'])),
self._objects) self._objects)
def objectMap(self): def objectMap(self):
...@@ -269,6 +276,7 @@ class ObjectManager( ...@@ -269,6 +276,7 @@ class ObjectManager(
aclEChecked='', aclAChecked=' CHECKED', aclPChecked='') aclEChecked='', aclAChecked=' CHECKED', aclPChecked='')
raise 'BadRequest', 'Unknown object type: %s' % type raise 'BadRequest', 'Unknown object type: %s' % type
def manage_delObjects(self,ids=[],submit='',clip_id='', def manage_delObjects(self,ids=[],submit='',clip_id='',
clip_data='',REQUEST=None): clip_data='',REQUEST=None):
"""Delete a subordinate object""" """Delete a subordinate object"""
...@@ -306,6 +314,7 @@ class ObjectManager( ...@@ -306,6 +314,7 @@ class ObjectManager(
if REQUEST is not None: if REQUEST is not None:
return self.manage_main(self, REQUEST, update_menu=1) return self.manage_main(self, REQUEST, update_menu=1)
def _setProperty(self,id,value,type='string'): def _setProperty(self,id,value,type='string'):
self._checkId(id) self._checkId(id)
self._properties=self._properties+({'id':id,'type':type},) self._properties=self._properties+({'id':id,'type':type},)
...@@ -477,6 +486,10 @@ class ObjectManager( ...@@ -477,6 +486,10 @@ class ObjectManager(
############################################################################## ##############################################################################
# #
# $Log: ObjectManager.py,v $ # $Log: ObjectManager.py,v $
# Revision 1.37 1998/03/18 17:54:29 brian
# Fixed bug that required objects to have a __len__ when a specifier was
# given to objectValues, Ids, and Items.
#
# Revision 1.36 1998/03/09 19:58:20 jim # Revision 1.36 1998/03/09 19:58:20 jim
# changed session marking support # changed session marking support
# #
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment