[Zope] setting a title to all objects in a folder?

Andreas Jung lists at zopyx.com
Wed Dec 27 12:43:42 EST 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



- --On 27. Dezember 2006 17:38:21 +0000 siva k <mannis2000 at hotmail.com>
wrote:

> Hello,
>
> Absolute newbie to python here. I try to set the SAME title to ALL the
> files in a
> zope folder using a python script.  The code below is not working... no
> idea why
>


> def setfiletitle(folder,title):
>     myfolder = getFolder(folder)
>     for file in myfolder:
>             setTitle(title)

Why should it work?

Do you think that code works just because you
write some methods without knowing about APIs and the frameworks
behind?

To get hold of an object by path: use restrictedTraverse()
To get hold of objects with a folder: folder.objectValues(9
To change a property of an object: someobject.manage_changeProperties()

<http://plope.com/Books/2_7Edition>


Untested:

def foo(self, folder_path, title):

  folder = self.restrictedTraverse(folder_path):
  for o in folder.objectValues():
     o.manage_changeProperties({'tite' : title})


- -aj
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (Darwin)

iD8DBQFFkrDQCJIWIbr9KYwRAoynAJ0SaYEBWvXUuu0CVO2vlLJcbi4tRgCfTh3G
kT1+YB2uZqtSXcQHt/Lq/KU=
=NQvG
-----END PGP SIGNATURE-----



More information about the Zope mailing list