[Zope] Renaming folder slow...

Reini Urban rurban@x-ray.at
Sat, 28 Jul 2001 13:53:13 +0100


btw: 
how do you programmatically rename some folder items?
I started with this, but I'm a complete newbie. it doesn't work.

import string, sys
import ZODB, OFS.ObjectManager

def main(folder='/path/to/Images'):
    '''Strip extensions (.gif, .jpg) from all images'''
    OFS.ObjectManager.checkValidId(OFS.ObjectManager,folder)
    get_transaction().begin()
    obj = OFS.ObjectManager._get_ob(folder)
    for img in obj.objectValues('Image'):
        new_id = img.id
        new_id = string.replace(new_id,'.gif','',1)
        new_id = string.replace(new_id,'.jpg','',1)
        new_id = string.replace(new_id,'.png','',1)
        if (new_id != img.id):
            img.manage_renameObject(img.id, new_id)
    get_transaction().commit() 

if __name__=='__main__':
    if len(sys.argv) > 1:
        main([sys.argv[1]])
    else:
        main()


sean.upton@uniontrib.com schrieb:
> I have a folder that contains a hierarchy that includes some code, and about
> 10,000 cataloged objects; renaming that folder is really slow; I'm just
> curious if anyone knows why?  Does the id of the folder have to be re-keyed
> in all of its children?
-- 
Reini Urban
http://xarch.tu-graz.ac.at/home/rurban/