Re: [Zope-DB] case insensitive ZSQL queries
thanks -- it now works like a charm Garry Saddington wrote: On Wed, 2007-09-05 at 16:16 -0700, onsombal wrote: is there an easy way to make the following ZSQL query case-insensitive? select * from clients dtml-sqlgroup where dtml-sqltest firstname op=like type=string optional dtml-or dtml-sqltest lastname op=like type=string optional dtml-or dtml-sqltest client op=like type=string optional /dtml-sqlgroup Thanks... Jim If you use Postgresql then change the 'like' to 'ilike'. Regards Garry ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db -- View this message in context: http://www.nabble.com/case-insensitive-ZSQL-queries-tf4388729.html#a12521162 Sent from the Zope - DB mailing list archive at Nabble.com. ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db
[Zope-DB] case insensitive ZSQL queries
is there an easy way to make the following ZSQL query case-insensitive? select * from clients dtml-sqlgroup where dtml-sqltest firstname op=like type=string optional dtml-or dtml-sqltest lastname op=like type=string optional dtml-or dtml-sqltest client op=like type=string optional /dtml-sqlgroup Thanks... Jim -- View this message in context: http://www.nabble.com/case-insensitive-ZSQL-queries-tf4388729.html#a12512815 Sent from the Zope - DB mailing list archive at Nabble.com. ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db
[Zope-DB] passing multiple variables via the url string
I'm attempting to pass multiple variables via the url string. field1 field2 are form variables to be passed on a redirect. field1 = 'foo' field2 = 'bar' For the command below, I do not get a python syntax error unless I remove the + symbols: return container.absolute_url()+'/my-documents/?field1='+field1'field2='+field2 Executing the command returns the following error: unsupported operand type(s) for : 'str' and 'str' The symbol from all my research should separate the variables. Does Zope use some other symbol? I can successfully pass either field1 or field2 using the same command with only one variable: return container.absolute_url()+'/my-documents/?field1='+field1 Thanks... Jim -- View this message in context: http://www.nabble.com/passing-multiple-variables-via-the-url-string-tf4365954.html#a12444521 Sent from the Zope - DB mailing list archive at Nabble.com. ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db
[Zope-DB] updating fields in a zsql method programmatically
Here's the scenario: 1. insertNew is a Z SQL Method for creating a new record in pgsql table1 Argument list = field1, field2, field3 SQL Query: INSERT INTO table1 (field1, field2, field3) VALUES ( dtml-sqlvar field1 type=string, dtml-sqlvar field2 type=string, dtml-sqlvar field3 type=string) 2. call_insertNew is a python script that is called as an After Validation Script by a pfg form request = container.REQUEST RESPONSE = request.RESPONSE form = request.form changed_field1 = form.get('field1') changed_field1 = a new computed value field1 = changed_field1 #create a new record with form field results for field2 field3, and a computed value for field1 context.insertNew() * It's easy to insert and update Z SQL Methods directly from form field results. It's easy to read form field results (e.g. request.field2) and do comparisons, etc. I am struggling to understand how one can change a form field result with a computed value from a python script. Either of the following returns an error: form.get('field1') = changed_field1 request.field1 = changed_field1 and... field1 = changed_field1 ...the value doesn't get posted to the pgsql record. Instead the pgsql field1 value remains what the request.field1 value was originally. Any direction is appreciated... Jim -- View this message in context: http://www.nabble.com/updating-fields-in-a-zsql-method-programmatically-tf4335404.html#a12347343 Sent from the Zope - DB mailing list archive at Nabble.com. ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db
Re: [Zope-DB] updating fields in a zsql method programmatically
I tried the techniques you suggested and it results in the same error -- KeyError: 'form.submitted' field1 = changed_field1 context.insertNew(field1=field1) -- I also tried the other technique and got the same error. I tried your technique with the following changes to my pfg (ploneformgen) for and Z SQL Method: 1. with field1, field2, field3 all included in the pfg (ploneformgen) form 2. with these same three fields excluded from the pfg form 3. with my Z SQL method argument as field1 4. with my Z SQL method argument as field1=field1 I just know that there has to be an easy solution to this problem. I'm assuming the form results are stored as an object represented as a dictionary. If so, then there must be a way for my python script to change the key | value pair for field1 before I call my Z SQL Method. Is this reasonable, or am I just going down a rat-hole? Thanks... Jim Maciej Wisniowski wrote: changed_field1 = a new computed value field1 = changed_field1 #create a new record with form field results for field2 field3, and a computed value for field1 context.insertNew() Obvious things are sometimes hardest to find ;) Try: field1 = changed_field1 context.insertNew(field1=field1) or even: context.insertNew(field1='something', field2=other_variable) It is more clear than getting values from context I think. -- Maciej Wisniowski ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db -- View this message in context: http://www.nabble.com/updating-fields-in-a-zsql-method-programmatically-tf4335404.html#a12356504 Sent from the Zope - DB mailing list archive at Nabble.com. ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db
Re: [Zope-DB] updating fields in a zsql method programmatically
So, my script now works!! Thanks to everyone for your input. It is greatly appreciated. Below is a quick summary of what I did and a relevant excerpt of the working script. 1) I never was able to get passing the arguments via the context.Statement to work. I'm sure it's something I've done wrong. 2) I successfully updated the context.REQUEST.form dictionary key:value pair with my computed value. The computed value was to replace the blank (hidden) 'fdbkurl' pfg form field with the url of a form object that was copied from a standard-template to another folder, and then renamed. After renaming, I re-indexed the object, and then captured its absolute url -- which I then used to update the dictionary key:value. Code follows: #copy, paste, rename std-survey to Folder from Products.CMFCore.utils import getToolByName urltool = getToolByName(context, portal_url) portal = urltool.getPortalObject() mydoc_folder = getToolByName(context, my-documents) crm_folder = getToolByName(context, crm) survey_folder = getToolByName(context, std-forms) listing_folder = getattr(mydoc_folder, listings) #manage_copyObjects(self, ids=None, REQUEST=None, RESPONSE=None) cb_copy_data = survey_folder.manage_copyObjects([std-survey]) dest = getattr(listing_folder, tls_id) #manage_pasteObjects(self, cb_copy_data=None, REQUEST=None) #Paste previously copied objects into the current object. #If calling manage_pasteObjects from python code, #pass the result of a previous call to manage_cutObjects or manage_copyObjects as the first argument. dest.manage_pasteObjects(cb_copy_data) #manage_renameObjects(self, ids=[], new_ids=[], REQUEST=None) tls_folder = getattr(listing_folder, tls_id) survey_id = survey + form.get('tls') survey_title = Survey + form.get('tls') survey_obj = getattr(tls_folder, std-survey) tls_folder.manage_renameObjects(ids=[std-survey], new_ids=[survey_id]) survey_obj.setTitle(survey_title) survey_obj.reindexObject() fbkurl = survey_obj.absolute_url() formresult['fbkurl'] = fbkurl #create record in usdb listing table context.listingsCreateRow() And it works! Charlie Clark-2 wrote: Am 27.08.2007, 21:59 Uhr, schrieb onsombal [EMAIL PROTECTED]: I'm assuming the form results are stored as an object represented as a dictionary. If so, then there must be a way for my python script to change the key | value pair for field1 before I call my Z SQL Method. Is this reasonable, or am I just going down a rat-hole? All form values are in the context.REQUEST.form dictionary which can overwrite to your heart's content. Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source Python/Zope Consulting and Support ...http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db -- View this message in context: http://www.nabble.com/updating-fields-in-a-zsql-method-programmatically-tf4335404.html#a12359442 Sent from the Zope - DB mailing list archive at Nabble.com. ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db