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

2006-12-28 Thread siva k


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 [EMAIL PROTECTED]
Reply-To: Andreas Jung [EMAIL PROTECTED]
To: siva k [EMAIL PROTECTED], zope@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 + 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-



_
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] Renaming all the zsql method's title in a given folder

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



- --On 28. Dezember 2006 18:33:27 + siva k [EMAIL PROTECTED]
wrote:


 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.



I am not trying to understand and I won't comment on the sense of your 
approach but you can rename objects using manage_renameObjects()...google
for details.

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

iD8DBQFFlA87CJIWIbr9KYwRAnL1AJ99KdI1P1QbHKt0eKoXtEgZznVaRwCg3rhS
glBYwVze+OtjoMl18yiXGn0=
=zSe8
-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 )