def manage_addMounts(dispatcher, paths=(), create_mount_points=True, REQUEST=None): """Adds MountedObjects at the requested paths. """ count = 0 app = dispatcher.getPhysicalRoot() for path in paths: mo = MountedObject(path) mo._create_mount_points = not not create_mount_points # Raise an error now if there is any problem. mo._test(app) blazer = SimpleTrailblazer(app) container = blazer.traverseOrConstruct(path, omit_final=1) container._p_jar.add(mo) loaded = mo.__of__(container) # Add a faux object to avoid generating manage_afterAdd() events # while appeasing OFS.ObjectManager._setObject(), then discreetly # replace the faux object with a MountedObject. faux = Folder() faux.id = mo.id faux.meta_type = loaded.meta_type container._setObject(faux.id, faux) # DM 2005-05-17: we want to keep our decision about automatic # mount point creation #del mo._create_mount_points container._setOb(faux.id, mo) setMountPoint(container, faux.id, mo) count += 1 if REQUEST is not None: REQUEST['RESPONSE'].redirect(REQUEST['URL1'] + ('/manage_main?manage_tabs_message=' 'Added %d mount points.' % count))
def manage_addMounts(dispatcher, paths=(), create_mount_points=True, REQUEST=None): """Adds MountedObjects at the requested paths. """ count = 0 app = dispatcher.getPhysicalRoot() for path in paths: mo = MountedObject(path) mo._create_mount_points = not not create_mount_points # Raise an error now if there is any problem. mo._test(app) blazer = SimpleTrailblazer(app) container = blazer.traverseOrConstruct(path, omit_final=1) container._p_jar.add(mo) loaded = mo.__of__(container) # Add a faux object to avoid generating manage_afterAdd() events # while appeasing OFS.ObjectManager._setObject(), then discreetly # replace the faux object with a MountedObject. faux = Folder() faux.id = mo.id faux.meta_type = loaded.meta_type container._setObject(faux.id, faux) # DM 2005-05-17: we want to keep our decision about automatic # mount point creation #del mo._create_mount_points container._setOb(faux.id, mo) setMountPoint(container, faux.id, mo) count += 1 if REQUEST is not None: REQUEST['RESPONSE'].redirect( REQUEST['URL1'] + ('/manage_main?manage_tabs_message=' 'Added %d mount points.' % count))