[Zope] Renaming all the zsql method's title in a given folder

siva k mannis2000 at hotmail.com
Thu Dec 28 13:33:27 EST 2006


Hi Andreas,

Thank you very mch for your help, your method works very well.
However, it fails to rename the zsql methods. The objective here is
to get rid of the transparent folder, but there are many sql methods
inside several transparent folders. The idea here is to give the path of 
transparent
folders as the the title to the zsql method , place them in the root, and 
then
move them to subfolders. I try another python script to rename only the zsql 
methods.
Its not working even when i hardcode foldername ad title in the pythonscript 
and call it in
a dtml method.

Please take a look at the code below

def zsql_set_title(self, folder_path, title):

   objs = self.ZopeFind(folder_path,
                 obj_metatypes=['Z SQL Method'],
                 search_sub=1)


   for  method in objs:

      title = title
      conn_id = method.connection_id
      args = method.arguments_src
      body = method.src
      method.manage_edit(title, conn_id, args, body)



Could you please spot the mistakes here?

Thanks


>From: Andreas Jung <lists at zopyx.com>
>Reply-To: Andreas Jung <lists at zopyx.com>
>To: siva k <mannis2000 at hotmail.com>, zope at zope.org
>Subject: Re: [Zope] setting a title to all objects in a folder?
>Date: Wed, 27 Dec 2006 18:43:42 +0100
>
>-----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-----
>

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



More information about the Zope mailing list