[Zope-DB] A new event.log on every restart of Zope
It would accelerate my Zope debugging cycle to have a new event.log file automatically started every time I restart Zope, with the old file preserved. It seems like a simple way to do this would be to modify the zope.conf eventlog entry, which currently reads like this. eventlog level info logfile path $INSTANCE/log/event.log level info /logfile /eventlog .so that the path line puts a now timestamp into the file name, something like this. path $INSTANCE/log/event'NOW' TIMESTAMP.log .so that the file name includes the Zope restart timestamp, something like this: event2008-07-15T13:30:09.log My question is: what would be the syntax for the zope.conf element I have shown above as 'NOW' TIMESTAMP? ~ TIA ~ Ken PS - I'm aware that there are various ways to rotate log files at time intervals or when they reach a certain size. That's not what I need. ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db
[Zope-DB] Seeking help with Accessing Zope from PostgreSQL
I'm trying to implement the scheme for Accessing Zope from PostgreSQL that is described in http://zope.org/Members/pupq/zope_in_pg. I'm trying to implement it in a Plone installation in a WinXP environment (Plone 2.5.2, Zope 2.9.6, Python 2.4.3, win32, PostgreSQL 8.1.10). I have changed the file paths in the above reference's zstart() function so that they refer to the appropriate (I hope) directories and files in my environment. My zstart() now reads like this: CREATE or REPLACE FUNCTION public.zstart() RETURNS pg_catalog.text AS ' if GD.has_key(zope_app): GD[app]._p_jar.sync() return import sys sys.path.insert(0, \Program Files\Plone 2\Zope\lib\python) sys.path.insert(0, \Program Files\Plone 2\Zope\lib\python\Products) import Zope sys.argv=[zope] Zope.configure(\Program Files\Plone 2\Zope\skel\etc\zope.conf.in) GD[zope_app]=Zope.app() from ZODB.Transaction import get_transaction GD[zope_get_trans]=get_transaction ' LANGUAGE 'plpythonu' VOLATILE; But when I try to run zstart() with this SQL: select zstart(); I get this error: PostgreSQL Error Code: (1) ERROR: plpython: function zstart failed DETAIL: exceptions.SystemExit: 2 0 Record(s) Returned Any suggestions to make this work? ~ TIA ~ Ken ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db
RE: [Zope-DB] Using dtml-vars in ZSQL methods?
-Original Message- From: Maciej Wisniowski [mailto:[EMAIL PROTECTED] Sent: Monday, June 18, 2007 1:34 AM To: Ken Winter Cc: 'Zope-DB List' Subject: Re: [Zope-DB] Using dtml-vars in ZSQL methods? I tried to invoke the query method of my adapter (which is named dhatabase) with this code: p = context.REQUEST.get('delete_this') if p: s = ', '.join([str(x) for x in p]) t = delete from person where person_id in (%s); % s context.dhatabase.query(query_string=t) ...and got this error: AttributeError: query (full traceback at end of message). What's wrong with my method call? Try: context.dhatabase().query(query_string=t) Assuming that 'dhatabase' is your DatabaseConnection object. Thanks, Maciej. That works fine! ~ Ken ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db
RE: [Zope-DB] Using dtml-vars in ZSQL methods?
Thanks Charlie Jim ~ SQL injection is a new one on me, and I'm glad to learn about it now (painlessly) rather than later (painfully). ~ Ken -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, June 18, 2007 10:03 AM To: Ken Winter Cc: 'Zope-DB List' Subject: RE: [Zope-DB] Using dtml-vars in ZSQL methods? I also have a broader question: When one is composing dynamic SQL in Python scripts, what are the pros and cons of executing them by going directly to the database adapter (as suggested above) vs passing it in as the sole argument of an empty ZSQL method? By empty ZQL method I mean something like: There are no pros and cons. Only cons. There is a good argument to be made that ZSQL methods are entirely a bad idea -- that only prepared statements should be supported, as it is far harder to break security. But, every use of dtml-var ... in a ZSQL method requires that the argument be examined and correctly SQL-Quoted. For example, what is to keep someone from entering 13225, 12337; delete from person in your web form? Further, you have greatly complicated verification and maintenance. It no longer is enough to test the ZSQL method to be sure that it operates as expected. You have to examine every call-point to determine what the SQL method is doing. And you have to examine every argument to be sure that it has been quoted properly and you aren't open to SQL injection. Charlie has already given the best answer -- use a really simple method like: delete from person where person_id = dtml-sqlvar foo type=int, and call it once for each person you have to delete. SQL injection is impossible, since foo is verified to be an int just before it is used. Now, there are times where dtml-var ... is unavoidable; IN clauses and LIKE clauses are the principal ones. In either case, you really need to verify the arguments. At the bare minimum, look at dtml-var ... sql_quote. jim penny ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db
RE: [Zope-DB] Using dtml-vars in ZSQL methods?
-Original Message- From: Charlie Clark [mailto:[EMAIL PROTECTED] Sent: Saturday, June 16, 2007 6:24 PM To: Ken Winter; 'Zope-DB List' Subject: Re: [Zope-DB] Using dtml-vars in ZSQL methods? ... FWIW you might want to call the query or execute methods directly on the DA connection object if they are supported. ZPsycopgDA is my database adapter. I haven't found any documentation of ZPsycopgDA's methods except its code. In the code, I found a class DB with a query method (which in turn uses execute and fetchall methods, whose definitions I can't locate). I tried to invoke the query method of my adapter (which is named dhatabase) with this code: p = context.REQUEST.get('delete_this') if p: s = ', '.join([str(x) for x in p]) t = delete from person where person_id in (%s); % s context.dhatabase.query(query_string=t) ...and got this error: AttributeError: query (full traceback at end of message). What's wrong with my method call? I also have a broader question: When one is composing dynamic SQL in Python scripts, what are the pros and cons of executing them by going directly to the database adapter (as suggested above) vs passing it in as the sole argument of an empty ZSQL method? By empty ZQL method I mean something like: dtml-comment title: Query whose whole body is passed in as an argument connection_id: dhatabase arguments: foo /dtml-comment dtml-var foo ~ Thanks ~ Ken P.S. Full details of error: Time 2007-06-17 13:59 User Name admin (admin) Request URL http://localhost/DAgroups/portal_factory/People/people.2007-06-17.6691253086 /people_edit Exception Type AttributeError Exception Value query Traceback (innermost last): * Module ZPublisher.Publish, line 115, in publish * Module ZPublisher.mapply, line 88, in mapply * Module ZPublisher.Publish, line 41, in call_object * Module Products.CMFPlone.FactoryTool, line 369, in __call__ * Module ZPublisher.mapply, line 88, in mapply * Module ZPublisher.Publish, line 41, in call_object * Module Products.CMFFormController.FSControllerPageTemplate, line 90, in __call__ * Module Products.CMFFormController.BaseControllerPageTemplate, line 28, in _call * Module Products.CMFFormController.ControllerBase, line 232, in getNext __traceback_info__: ['id = people_edit', 'status = success', 'button=delete', 'errors={}', 'context=People at people.2007-06-17.6691253086', kwargs={'portal_status_message': 'People allegedly deleted: 69394, 77084'}, 'next_action=None', ''] * Module Products.CMFFormController.Actions.TraverseTo, line 38, in __call__ * Module ZPublisher.mapply, line 88, in mapply * Module ZPublisher.Publish, line 41, in call_object * Module Products.CMFFormController.FSControllerPythonScript, line 104, in __call__ * Module Products.CMFFormController.Script, line 145, in __call__ * Module Products.CMFCore.FSPythonScript, line 108, in __call__ * Module Shared.DC.Scripts.Bindings, line 311, in __call__ * Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec * Module Products.CMFCore.FSPythonScript, line 164, in _exec * Module None, line 6, in people_delete_control FSControllerPythonScript at /DAgroups/people_delete_control used for /DAgroups/portal_factory/People/people.2007-06-17.6691253086 Line 6 AttributeError: query REQUEST form delete_this [69394, 77084] form.button.delete 'Delete Selected People' cookies tree-s 'eJzTyCkw5NLIKTDiClZ3hANXW3WuAmOuRKCECUjWFEnWNTEbJGvGlQgEegAEWRAt' __ac'YWRtaW46cHAyMTA3' lazy items SESSION bound method SessionDataManager.getSessionData of SessionDataManager at /session_data_manager other tree-s 'eJzTyCkw5NLIKTDiClZ3hANXW3WuAmOuRKCECUjWFEnWNTEbJGvGlQgEegAEWRAt' __factory__info__ {'stack': ['People', 'people.2007-06-17.6691253086', 'people_edit'], 'People': TempFolder at /DAgroups/portal_factory/People} URL5'http://localhost' URL4'http://localhost/DAgroups' __ac'YWRtaW46cHAyMTA3' URL0 'http://localhost/DAgroups/portal_factory/People/people.2007-06-17.669125308 6/people_edit' URL3'http://localhost/DAgroups/portal_factory' URL2'http://localhost/DAgroups/portal_factory/People' AUTHENTICATION_PATH '' AUTHENTICATED_USER PropertiedUser 'admin' SERVER_URL 'http://localhost' delete_this [69394, 77084] form.button.delete 'Delete Selected People' ACTUAL_URL 'http://localhost/DAgroups/portal_factory/People/people.2007-06-17.669125308 6/people_edit' portal_status_message 'People allegedly deleted: 69394, 77084' URL 'http://localhost/DAgroups/portal_factory/People/people.2007-06-17.669125308 6/people_edit' PUBLISHED FactoryTool at /DAgroups/portal_factory controller_state Products.CMFFormController.ControllerState.ControllerState object at 0x0681DB10 TraversalRequestNameStack [] BASE0 'http://localhost' BASE1 'http://localhost/DAgroups' BASE2 'http://localhost/DAgroups/portal_factory' BASE3
RE: [Zope-DB] Using dtml-vars in ZSQL methods?
Jaroslav ~ I'm pretty sure that 'delete_this' is a list (of integers), because the lines p = context.REQUEST.get('delete_this') s = ', '.join([str(x) for x in p]) process it correctly into the string 's'. In other words, I think it is the same as if p had been assigned a list in this way: p = [9765, 10058, 11333] s = ', '.join([str(x) for x in p]) In either case, s ends up as the string 9765, 10058, 11333. That's what gets passed to the ZSQL method (below), and that's where the trouble seems to be. I will put in another message to this thread documenting some further experiments I have done. ~ Thanks ~ Ken -Original Message- From: Jaroslav Lukesh [mailto:[EMAIL PROTECTED] Sent: Saturday, June 16, 2007 1:41 AM To: Ken Winter; 'Zope-DB List' Subject: Re: [Zope-DB] Using dtml-vars in ZSQL methods? It is just because 'delete_this' is a string, not the list, or vice versa? - Original Message - From: Ken Winter [EMAIL PROTECTED] To: 'Zope-DB List' zope-db@zope.org Sent: Saturday, June 16, 2007 5:15 AM Subject: [Zope-DB] Using dtml-vars in ZSQL methods? Here's the definition of a ZSQL method, people_delete_by_id.zsql: dtml-comment title: Method to delete People by ids given in a comma-separated list connection_id: my_database arguments: id_list /dtml-comment delete from person where person_id in (dtml-var id_list) Here's the puzzle: When I define and test this ZSQL method through the ZMI, passing it a string such as 9765, 10058, 11333, it indeed deletes the rows with those values on person_id. BUT when I invoke the same ZSQL method from a Python script with the following code: p = context.REQUEST.get('delete_this') if p: s = ', '.join([str(x) for x in p]) context.people_delete_by_id(id_list=s) ...and with a REQUEST variable 'delete_this' that comes from this snippet of a form in a page template: form method=post name=form2 tal:attributes=action string:${here/absolute_url}/${template/id}; input type=hidden name=form.submitted value=1 / p class=error_message tal:define=err errors/n|nothing tal:condition=errb tal:content=err //p table tr tal:repeat=person options/dataa name=id id=id tal:attributes=name person/person_id/a td tal:condition=not:options/selectall | nothing input type=checkbox name=delete_this:list:int value= tal:attributes=value person/person_id/ /td ... /tr /table ... /form ...and with the same three person_ids (9765, 10058, 11333) the 4th line of the Python script evokes an error: KeyError: 'id_list' The core idea is that the string id_list is passed into the ZSQL method, where it is spliced into the delete...where clause via the dtml-var id_list) to provide the list of person_ids to delete. Here's the question: WHY? ~ TIA ~ Ken P.S. I know that dtml-var... rather than dtml-sqlvar... is an unorthodox and apparently undocumented construct to use within a ZSQL definition. But I need it because dtml-sqlvar... malformats the string. And if doing this trick is a no-no, how come it works in the ZMI test but not when called from Python? More importantly, how can I get it to work from Python? ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db
RE: [Zope-DB] Using dtml-vars in ZSQL methods?
2.9.6-final, python 2.4.3, win32) ZServer/1.1 Plone/2.5.2' SCRIPT_NAME '' REQUEST_METHOD 'POST' HTTP_KEEP_ALIVE '300' SERVER_PROTOCOL 'HTTP/1.1' channel.creation_time 1182022394 CONNECTION_TYPE 'keep-alive' HTTP_ACCEPT_CHARSET 'ISO-8859-1,utf-8;q=0.7,*;q=0.7' HTTP_USER_AGENT 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1' HTTP_REFERER 'http://localhost/DAgroups/portal_factory/People/people.2007-06-16.362593180 8/people_edit' SERVER_NAME 'KenIBM' REMOTE_ADDR '127.0.0.1' PATH_TRANSLATED '\\DAgroups\\portal_factory\\People\\people.2007-06-16.3625931808\\people_ed it' SERVER_PORT '80' CONTENT_LENGTH '89' HTTP_HOST 'localhost' HTTP_ACCEPT 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q =0.8,image/png,*/*;q=0.5' GATEWAY_INTERFACE 'CGI/1.1' HTTP_ACCEPT_LANGUAGE'en-us,en;q=0.5' CONTENT_TYPE'application/x-www-form-urlencoded' HTTP_ACCEPT_ENCODING'gzip,deflate' PATH_INFO '/DAgroups/portal_factory/People/people.2007-06-16.3625931808/people_edit' Let me add that I get the same error (down to all the details) if I simply put a single string or integer constant into the call to the ZSQL Method - that is, if instead of this context.people_delete_by_id(id_list=s) the call looks like this: context.people_delete_by_id(id_list=str(68775)) or context.people_delete_by_id(id_list=68775) That's why I think the problem has nothing to do with the prior processing of the list into a string. ~ Thanks ~ Ken -Original Message- From: Andreas Jung [mailto:[EMAIL PROTECTED] Sent: Saturday, June 16, 2007 3:27 PM To: Ken Winter; 'Zope-DB List' Subject: RE: [Zope-DB] Using dtml-vars in ZSQL methods? ... Second..it would be *really* helpful to see the full traceback instead of just *Keyerror*. It's somewhat boring to ask every time for it :-) --On 16. Juni 2007 15:19:10 -0400 Ken Winter [EMAIL PROTECTED] wrote: Jaroslav ~ I'm pretty sure that 'delete_this' is a list (of integers), because the lines p = context.REQUEST.get('delete_this') s = ', '.join([str(x) for x in p]) process it correctly into the string 's'. In other words, I think it is the same as if p had been assigned a list in this way: p = [9765, 10058, 11333] s = ', '.join([str(x) for x in p]) In either case, s ends up as the string 9765, 10058, 11333. That's what gets passed to the ZSQL method (below), and that's where the trouble seems to be. I will put in another message to this thread documenting some further experiments I have done. ~ Thanks ~ Ken -Original Message- From: Jaroslav Lukesh [mailto:[EMAIL PROTECTED] Sent: Saturday, June 16, 2007 1:41 AM To: Ken Winter; 'Zope-DB List' Subject: Re: [Zope-DB] Using dtml-vars in ZSQL methods? It is just because 'delete_this' is a string, not the list, or vice versa? - Original Message - From: Ken Winter [EMAIL PROTECTED] To: 'Zope-DB List' zope-db@zope.org Sent: Saturday, June 16, 2007 5:15 AM Subject: [Zope-DB] Using dtml-vars in ZSQL methods? Here's the definition of a ZSQL method, people_delete_by_id.zsql: dtml-comment title: Method to delete People by ids given in a comma-separated list connection_id: my_database arguments: id_list /dtml-comment delete from person where person_id in (dtml-var id_list) Here's the puzzle: When I define and test this ZSQL method through the ZMI, passing it a string such as 9765, 10058, 11333, it indeed deletes the rows with those values on person_id. BUT when I invoke the same ZSQL method from a Python script with the following code: p = context.REQUEST.get('delete_this') if p: s = ', '.join([str(x) for x in p]) context.people_delete_by_id(id_list=s) ...and with a REQUEST variable 'delete_this' that comes from this snippet of a form in a page template: form method=post name=form2 tal:attributes=action string:${here/absolute_url}/${template/id}; input type=hidden name=form.submitted value=1 / p class=error_message tal:define=err errors/n|nothing tal:condition=errb tal:content=err //p table tr tal:repeat=person options/dataa name=id id=id tal:attributes=name person/person_id/a td tal:condition=not:options/selectall | nothing input type=checkbox name=delete_this:list:int value= tal:attributes=value person/person_id/ /td ... /tr /table ... /form ...and with the same three person_ids (9765, 10058, 11333) the 4th line of the Python script evokes an error: KeyError: 'id_list' The core idea is that the string id_list is passed into the ZSQL method, where it is spliced into the delete...where clause via the dtml-var id_list) to provide the list of person_ids to delete. Here's the question: WHY? ~ TIA ~ Ken P.S. I know that dtml-var... rather than dtml-sqlvar
RE: [Zope-DB] Using dtml-vars in ZSQL methods?
Charlie ~ I tried several experiments based on your suggestion. See results inserted below. ~ Thanks, Ken -Original Message- From: Charlie Clark [mailto:[EMAIL PROTECTED] Sent: Saturday, June 16, 2007 3:54 PM To: Ken Winter; 'Zope-DB List' Subject: Re: [Zope-DB] Using dtml-vars in ZSQL methods? Am 16.06.2007, 21:19 Uhr, schrieb Ken Winter [EMAIL PROTECTED]: p = [9765, 10058, 11333] s = ', '.join([str(x) for x in p]) s gets passed to the ZSQL method, and that's where the trouble seems to be. I find this code a bit convoluted and somewhat dangerous if you are passing data from a web form. What's wrong with repeatedly calling a delete_person() method that just accepts a single id as a dtml-sqlvar? This stuff is coming from a web form so it probably won't be a huge list so the speed won't matter. EXPERIMENT #1: I tried this out by rewriting this part of the .cpy script to: p = context.REQUEST.get('delete_this') for id in p: context.person_delete_by_id(person_id=id) where person_delete_by_id is defined as follows (note that again I'm using a dtml-var... rather than a dtml-sqlvar here): dtml-comment title: Method to delete one Person by id connection_id: dhatabase arguments: person_id /dtml-comment delete from person where person_id = dtml-var person_id When I tried to delete a couple of People using this I got the error message: ProgrammingError: column none does not exist Here are the details of the error: Request URL http://localhost/DAgroups/portal_factory/People/people.2007-06-16.3625931808 /people_edit Exception Type ProgrammingError Exception Value column none does not exist Traceback (innermost last): * Module ZPublisher.Publish, line 115, in publish * Module ZPublisher.mapply, line 88, in mapply * Module ZPublisher.Publish, line 41, in call_object * Module Products.CMFPlone.FactoryTool, line 369, in __call__ * Module ZPublisher.mapply, line 88, in mapply * Module ZPublisher.Publish, line 41, in call_object * Module Products.CMFFormController.FSControllerPageTemplate, line 90, in __call__ * Module Products.CMFFormController.BaseControllerPageTemplate, line 28, in _call * Module Products.CMFFormController.ControllerBase, line 232, in getNext __traceback_info__: ['id = people_edit', 'status = success', 'button=delete', 'errors={}', 'context=People at people.2007-06-16.3625931808', kwargs={'portal_status_message': 'People allegedly deleted: 68775, 69390'}, 'next_action=None', ''] * Module Products.CMFFormController.Actions.TraverseTo, line 38, in __call__ * Module ZPublisher.mapply, line 88, in mapply * Module ZPublisher.Publish, line 41, in call_object * Module Products.CMFFormController.FSControllerPythonScript, line 104, in __call__ * Module Products.CMFFormController.Script, line 145, in __call__ * Module Products.CMFCore.FSPythonScript, line 108, in __call__ * Module Shared.DC.Scripts.Bindings, line 311, in __call__ * Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec * Module Products.CMFCore.FSPythonScript, line 164, in _exec * Module None, line 4, in people_delete_control FSControllerPythonScript at /DAgroups/people_delete_control used for /DAgroups/portal_factory/People/people.2007-06-16.3625931808 Line 4 * Module Shared.DC.ZRDB.DA, line 495, in __call__ FSZSQLMethod at /DAgroups/person_delete_by_id used for /DAgroups/portal_factory/People/people.2007-06-16.3625931808 * Module Products.ZPsycopgDA.db, line 204, in query ProgrammingError: column none does not exist REQUEST form delete_this [68775, 69390] form.button.delete 'Delete Selected People' cookies tree-s 'eJzTyCkw5NLIKTDiClZ3hANXW3WuAmOuRKCECUjWFEnWNTEbJGvGlQgEegAEWRAt' __ac'YWRtaW46cHAyMTA3' lazy items SESSION bound method SessionDataManager.getSessionData of SessionDataManager at /session_data_manager other tree-s 'eJzTyCkw5NLIKTDiClZ3hANXW3WuAmOuRKCECUjWFEnWNTEbJGvGlQgEegAEWRAt' __factory__info__ {'stack': ['People', 'people.2007-06-16.3625931808', 'people_edit'], 'People': TempFolder at /DAgroups/portal_factory/People} URL5'http://localhost' URL4'http://localhost/DAgroups' __ac'YWRtaW46cHAyMTA3' URL0 'http://localhost/DAgroups/portal_factory/People/people.2007-06-16.362593180 8/people_edit' URL3'http://localhost/DAgroups/portal_factory' URL2'http://localhost/DAgroups/portal_factory/People' AUTHENTICATION_PATH '' AUTHENTICATED_USER PropertiedUser 'admin' SERVER_URL 'http://localhost' delete_this [68775, 69390] form.button.delete 'Delete Selected People' ACTUAL_URL 'http://localhost/DAgroups/portal_factory/People/people.2007-06-16.362593180 8/people_edit' portal_status_message 'People allegedly deleted: 68775, 69390' URL 'http://localhost/DAgroups/portal_factory/People/people.2007-06-16.362593180 8/people_edit' PUBLISHED FactoryTool at /DAgroups
[Zope-DB] Using dtml-vars in ZSQL methods?
Here's the definition of a ZSQL method, people_delete_by_id.zsql: dtml-comment title: Method to delete People by ids given in a comma-separated list connection_id: my_database arguments: id_list /dtml-comment delete from person where person_id in (dtml-var id_list) Here's the puzzle: When I define and test this ZSQL method through the ZMI, passing it a string such as 9765, 10058, 11333, it indeed deletes the rows with those values on person_id. BUT when I invoke the same ZSQL method from a Python script with the following code: p = context.REQUEST.get('delete_this') if p: s = ', '.join([str(x) for x in p]) context.people_delete_by_id(id_list=s) ...and with a REQUEST variable 'delete_this' that comes from this snippet of a form in a page template: form method=post name=form2 tal:attributes=action string:${here/absolute_url}/${template/id}; input type=hidden name=form.submitted value=1 / p class=error_message tal:define=err errors/n|nothing tal:condition=errb tal:content=err //p table tr tal:repeat=person options/dataa name=id id=id tal:attributes=name person/person_id/a td tal:condition=not:options/selectall | nothing input type=checkbox name=delete_this:list:int value= tal:attributes=value person/person_id/ /td ... /tr /table ... /form ...and with the same three person_ids (9765, 10058, 11333) the 4th line of the Python script evokes an error: KeyError: 'id_list' The core idea is that the string id_list is passed into the ZSQL method, where it is spliced into the delete...where clause via the dtml-var id_list) to provide the list of person_ids to delete. Here's the question: WHY? ~ TIA ~ Ken P.S. I know that dtml-var... rather than dtml-sqlvar... is an unorthodox and apparently undocumented construct to use within a ZSQL definition. But I need it because dtml-sqlvar... malformats the string. And if doing this trick is a no-no, how come it works in the ZMI test but not when called from Python? More importantly, how can I get it to work from Python? ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db
RE: [Zope-DB] Two actions in one ZSQL method = one transaction?
-Original Message- From: Andreas Jung [mailto:[EMAIL PROTECTED] Sent: Thursday, June 14, 2007 12:54 AM To: Ken Winter; 'Zope-DB List' Subject: Re: [Zope-DB] Two actions in one ZSQL method = one transaction? ... Does a ZSQL method initiate a database transaction, so that no other user can inset another record between the two actions in this ZSQL method? *If* you database provides transaction support and *if* your DA integrates with the transaction of Zope *then* everything happening within one Zope request will happen within one Zope transaction and therefore within one DB transaction. This isn't necessarily true to databases like MySQL. -aj My database is PostgreSQL 8.x and my adapter is ZPsyocopgDA. Does this combination provide the transaction support you're talking about? ~ Thanks ~ Ken ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db
RE: [Zope-DB] Two actions in one ZSQL method = one transaction?
Great! Thanks again. -Original Message- From: Andreas Jung [mailto:[EMAIL PROTECTED] Sent: Thursday, June 14, 2007 10:48 AM To: Ken Winter; 'Andreas Jung'; 'Zope-DB List' Subject: RE: [Zope-DB] Two actions in one ZSQL method = one transaction? --On 14. Juni 2007 10:41:46 -0400 Ken Winter [EMAIL PROTECTED] wrote: -Original Message- From: Andreas Jung [mailto:[EMAIL PROTECTED] Sent: Thursday, June 14, 2007 12:54 AM To: Ken Winter; 'Zope-DB List' Subject: Re: [Zope-DB] Two actions in one ZSQL method = one transaction? ... Does a ZSQL method initiate a database transaction, so that no other user can inset another record between the two actions in this ZSQL method? *If* you database provides transaction support and *if* your DA integrates with the transaction of Zope *then* everything happening within one Zope request will happen within one Zope transaction and therefore within one DB transaction. This isn't necessarily true to databases like MySQL. -aj My database is PostgreSQL 8.x and my adapter is ZPsyocopgDA. Does this combination provide the transaction support you're talking about? *Of course* -aj ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db
[Zope-DB] Two actions in one ZSQL method = one transaction?
I have a question (stated in three different ways) about the following ZSQL method: 1. Will it *always* return the person_id of the person that it just inserted? 2. Will it do this even if another user inserted another person just in between the two SQL actions in this ZSQL method? 3. In other words: Does a ZSQL method initiate a database transaction, so that no other user can inset another record between the two actions in this ZSQL method? Here's the ZSQL method: dtml-comment title: Method to add a Person and return the id of the Person just created connection_id: dhatabase arguments: first_name middle_names last_name /dtml-comment insert into person (first_name, middle_names, last_name) values ( dtml-sqlvar first_name type=string, dtml-sqlvar middle_names type=string, dtml-sqlvar last_name type=string ); select person_id from person where person_id = (select max(person_id) from person); ~ TIA ~ Ken ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db
RE: [Zope-DB] Seeking a suitable ZpsycopgDA
Correction: What I'm looking for seems to be called ZpsycopgDA, not just psycopgDA. Anyway, I still haven't found it for the environment described below. Pls advise. ~ TIAA ~ Ken -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ken Winter Sent: Monday, April 30, 2007 7:04 PM To: Zope-DB List Subject: [Zope-DB] Seeking a suitable psycopgDA I'm looking for the right version of psycopgDA for the following setup: Windows XP PostgreSQL 8.0 Zope 2.9.6-final Plone 2.5.2 (don't know if that matters) Python 2.4.3 Psycopg = win-psycopg24-pg8.0.zip downloaded from http://stickpeople.com/projects/python/win-psycopg/ MX Toolkit = egenix-mx-base-2.0.6.win32-py2.4.exe downloaded from http://www.egenix.com/files/python/eGenix-mx-Extensions.html I would hope to get the psycopgDA in binary or .msi form, or just as files I can dump into a directory, as I'm really not set up to compile and build stuff. Can you tell me where to find it? ~ TIA ~ Ken ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db
[Zope-DB] Seeking a suitable psycopgDA
I'm looking for the right version of psycopgDA for the following setup: Windows XP PostgreSQL 8.0 Zope 2.9.6-final Plone 2.5.2 (don't know if that matters) Python 2.4.3 Psycopg = win-psycopg24-pg8.0.zip downloaded from http://stickpeople.com/projects/python/win-psycopg/ MX Toolkit = egenix-mx-base-2.0.6.win32-py2.4.exe downloaded from http://www.egenix.com/files/python/eGenix-mx-Extensions.html I would hope to get the psycopgDA in binary or .msi form, or just as files I can dump into a directory, as I'm really not set up to compile and build stuff. Can you tell me where to find it? ~ TIA ~ Ken ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db