try with 2.2.1, it's the one I tested

On Thursday, November 8, 2012 4:58:50 AM UTC+1, Cliff Kachinske wrote:
>
> Version 2.0.9, Postgres 9.X, Psycopg2
>
> I don't know what else to tell you, except I know the record was there 
> after the failed delete attempt.
>
> Today the same syntax failed in another location in my code, with the same 
> result.  I thought I caught them all, but apparently not.
>
> On Wednesday, November 7, 2012 8:32:59 AM UTC-5, Niphlod wrote:
>>
>> but I tried in a shell and it doesn't raise an exception if the record 
>> exists (and it gets correctly deleted too)
>>
>> On Wednesday, November 7, 2012 1:59:48 PM UTC+1, Cliff Kachinske wrote:
>>>
>>> The record was there.
>>>
>>> That's the problem.  The shortcut was erroneously reporting that it was 
>>> gone.
>>>
>>> On Tuesday, November 6, 2012 2:40:38 PM UTC-5, Niphlod wrote:
>>>>
>>>> del db.sometable[something] requires that the id == something exists.
>>>> db(db.sometable.id == something).delete() instead returns the number 
>>>> of records deleted if there was any, otherwise it simply deletes nothing.
>>>>
>>>> On Tuesday, November 6, 2012 8:14:33 PM UTC+1, Cliff Kachinske wrote:
>>>>>
>>>>> This code works.  Note the commented out line.
>>>>>
>>>>>     for v in form.vars:
>>>>>         if v[:7] == 'remove_' and form.vars[v] == 'on':
>>>>>             # del db.class_users[v[7:]]
>>>>>             db(db.class_users.id==v[7:]).delete()
>>>>>
>>>>>
>>>>> This code, which should be equivalent, raises the exception shown below.
>>>>>
>>>>>     for v in form.vars:
>>>>>         if v[:7] == 'remove_' and form.vars[v] == 'on':
>>>>>             del db.class_users[v[7:]]
>>>>>
>>>>>
>>>>> Traceback (most recent call last):
>>>>>   File "/home/cjk/w2p09/web2py/gluon/restricted.py", line 209, in 
>>>>> restricted
>>>>>     exec ccode in environment
>>>>>   File 
>>>>> "/home/cjk/w2p09/web2py/applications/Training/controllers/class_users.py" 
>>>>> <http://localhost:8000/admin/default/edit/Training/controllers/class_users.py>,
>>>>>  line 371, in <module>
>>>>>   File "/home/cjk/w2p09/web2py/gluon/globals.py", line 186, in <lambda>
>>>>>     self._caller = lambda f: f()
>>>>>   File "/home/cjk/w2p09/web2py/gluon/tools.py", line 2809, in f
>>>>>     return action(*a, **b)
>>>>>   File 
>>>>> "/home/cjk/w2p09/web2py/applications/Training/controllers/class_users.py" 
>>>>> <http://localhost:8000/admin/default/edit/Training/controllers/class_users.py>,
>>>>>  line 165, in list_
>>>>>     if form.process(onvalidation=do_updates).accepted:
>>>>>   File "/home/cjk/w2p09/web2py/gluon/html.py", line 2108, in process
>>>>>     self.validate(**kwargs)
>>>>>   File "/home/cjk/w2p09/web2py/gluon/html.py", line 2055, in validate
>>>>>     if self.accepts(**kwargs):
>>>>>   File "/home/cjk/w2p09/web2py/gluon/html.py", line 1969, in accepts
>>>>>     onvalidation(self)
>>>>>   File 
>>>>> "/home/cjk/w2p09/web2py/applications/Training/controllers/class_users.py" 
>>>>> <http://localhost:8000/admin/default/edit/Training/controllers/class_users.py>,
>>>>>  line 134, in do_updates
>>>>>     del db.class_users[v[7:]]
>>>>>   File "/home/cjk/w2p09/web2py/gluon/dal.py", line 7691, in __delitem__
>>>>>     raise SyntaxError, 'No such record: %s' % key
>>>>> SyntaxError: No such record: 7
>>>>>
>>>>>

-- 



Reply via email to