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

2006-12-27 Thread siva k

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)



could you please say where did i go wrong?

Thanks

_
Express yourself instantly with MSN Messenger! Download today it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


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

2006-12-27 Thread Andreas Jung
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1



- --On 27. Dezember 2006 17:38:21 + siva k [EMAIL PROTECTED]
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-

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )