[Zope] what if the query gives no records?
Hi, A very basic question: a dtml-in loop calls an zsql method it works fine when there is data but when there is no data it should display no records found. But it displays nothing when there are no records. Please suggest a soultion dtml-in select_something(parameter=parameter ,parameter1=parameter1) dtml-if _['sequence-start']==_['sequence-end'] no records found dtml-else dtml-var fieldname /dtml-if /dtml-in 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: Re: [Zope] dynamically generating sql queries?
Hi, Thank you very much for your answer. As you suggested, i concatenate the string with an integer to create a fieldname and then pass it to zsql object along with language argument. I do everything inside a Script (Python) object that accepts 3 arguments (field,index,language)now. - result=field+str(index) res=context.select_sql(field=result, language=language) print res[0].result return printed - I test this python script inside ZMI and run into problems. It works only if I explicitly specify the columname like print res[0].author_1. another question- how can one specify row index here?(res[row index]). Each language has one row. 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 )
[Zope] dynamically generating sql queries?
Hi, I have five fields in the database author1,author2..author5. Trying to generate a parameter for the select_sql method called result, I run into an error -cannot add type int to string. Could you please say how to concatenate a string and a number? please look at the code.. -- dtml-in _.range(1,6) dtml-call REQUEST.set('field','author') dtml-let field=field index=sequence-index result=field+index dtml-in select_sql(field=result , language=language) dtml-var sequence-key /dtml-in /dtml-let /dtml-in -- or is there a better way to generate 5 different sql quesries and display the result? thank you. _ 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 )
[Zope] Renaming all the zsql method's title in a given folder
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 )
[Zope] setting a title to all objects in a folder?
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 )