Andreas ~ Here's the whole traceback (and all the other details from my Plone error log):
" Time 2007-06-16 15:33 User Name admin (admin) Request URL http://localhost/DAgroups/portal_factory/People/people.2007-06-16.3625931808 /people_edit Exception Type KeyError Exception Value 'id_list' 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'}", '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 481, in __call__ <FSZSQLMethod at /DAgroups/people_delete_by_id used for /DAgroups/portal_factory/People/people.2007-06-16.3625931808> * Module DocumentTemplate.DT_String, line 476, in __call__ KeyError: 'id_list' Display traceback as text REQUEST form delete_this [68775] 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] 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' URL 'http://localhost/DAgroups/portal_factory/People/people.2007-06-16.362593180 8/people_edit' PUBLISHED <FactoryTool at /DAgroups/portal_factory> controller_state <Products.CMFFormController.ControllerState.ControllerState object at 0x0663CEB0> TraversalRequestNameStack [] BASE0 'http://localhost' BASE1 'http://localhost/DAgroups' BASE2 'http://localhost/DAgroups/portal_factory' BASE3 'http://localhost/DAgroups/portal_factory/People' BASE4 'http://localhost/DAgroups/portal_factory/People/people.2007-06-16.362593180 8' BASE5 'http://localhost/DAgroups/portal_factory/People/people.2007-06-16.362593180 8/people_edit' URL1 'http://localhost/DAgroups/portal_factory/People/people.2007-06-16.362593180 8' URL0 http://localhost/DAgroups/portal_factory/People/people.2007-06-16.3625931808 /people_edit URL1 http://localhost/DAgroups/portal_factory/People/people.2007-06-16.3625931808 URL2 http://localhost/DAgroups/portal_factory/People URL3 http://localhost/DAgroups/portal_factory URL4 http://localhost/DAgroups URL5 http://localhost BASE0 http://localhost BASE1 http://localhost/DAgroups BASE2 http://localhost/DAgroups/portal_factory BASE3 http://localhost/DAgroups/portal_factory/People BASE4 http://localhost/DAgroups/portal_factory/People/people.2007-06-16.3625931808 BASE5 http://localhost/DAgroups/portal_factory/People/people.2007-06-16.3625931808 /people_edit environ HTTP_COOKIE 'tree-s="eJzTyCkw5NLIKTDiClZ3hANXW3WuAmOuRKCECUjWFEnWNTEbJGvGlQgEegAEWRAt"; __ac="YWRtaW46cHAyMTA3"' SERVER_SOFTWARE 'Zope/(Zope 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-var>s 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-var>s 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-var>s 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="err"><b tal:content="err" /></p> > >> > >> <table> > >> <tr tal:repeat="person options/data"><a 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 > > > > -- > ZOPYX Ltd. & Co. KG - Charlottenstr. 37/1 - 72070 Tübingen - Germany > Web: www.zopyx.com - Email: [EMAIL PROTECTED] - Phone +49 - 7071 - 793376 > Registergericht: Amtsgericht Stuttgart, Handelsregister A 381535 > Geschäftsführer/Gesellschafter: ZOPYX Limited, Birmingham, UK > ------------------------------------------------------------------------ > E-Publishing, Python, Zope & Plone development, Consulting _______________________________________________ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db