Sorry, this is (part of) my db.py:

db.define_table('contenido', \
  Field('titulo'), \
  Field('slug'), \
  Field('fecha_hora', 'datetime'), \
  Field('detalle', 'text'), \
  Field('cuerpo', 'text'), \
  Field('autor'), \
  Field('meta_description'))


db.define_table('galeria_contenido', \
  Field('contenido', db.contenido, ondelete='NO ACTION'), \
  Field('orden', 'integer'), \
  Field('titulo'), \
  Field('detalle', 'text'))


On the other hand, a controller with a function that tries to delete a 
"noticia" (spanish for "news"):

def _eliminar_borrador():
    noticia = db.contenido[request.post_vars.noticia]
    noticia.galeria_contenido.delete()
    db(db.contenido.id==noticia.id).delete()
    return response.json({'success':True})


The line that throws the error is this:
noticia.galeria_contenido.delete()



Here I post again the traceback:

Traceback (most recent call last):
  File "/home/gonguinguen/medios/gluon/restricted.py", line 227, in restricted
    exec ccode in environment
  File 
"/home/gonguinguen/medios/applications/demo_panel/controllers/contenido.py" 
<http://localhost/admin/edit/demo_panel/controllers/contenido.py>, line 459, in 
<module>
  File "/home/gonguinguen/medios/gluon/globals.py", line 412, in <lambda>
    self._caller = lambda f: f()
  File "/home/gonguinguen/medios/gluon/tools.py", line 3583, in f
    return action(*a, **b)
  File 
"/home/gonguinguen/medios/applications/demo_panel/controllers/contenido.py" 
<http://localhost/admin/edit/demo_panel/controllers/contenido.py>, line 436, in 
_eliminar_borrador
    noticia.galeria_contenido.delete()
  File "/home/gonguinguen/medios/gluon/packages/dal/pydal/helpers/classes.py", 
line 348, in __getattr__
    raise AttributeError
AttributeError


That sentence is executed without errors if I write it this way:
db(db.galeria_contenido.contenido==noticia.id).delete()


I think both sentences are valid. The first one only fails with web2py 
2.11.2, but works ok with 2.10.3.


El lunes, 3 de agosto de 2015, 12:20:40 (UTC-3), Niphlod escribió:
>
> an app to reproduce the issue (or at least a model definition!) would be 
> fine to spot the error.
>
> On Monday, August 3, 2015 at 2:13:45 PM UTC+2, Lisandro wrote:
>>
>> I've upgraded from version 2.10.3 to last stable version 2.11.2, but 
>> after the upgrade, an error is thrown when trying to delete a subset 
>> through one to many relation.
>>
>> Consider the example of the book (table "person", and table "thing", each 
>> thing is owned by one person):
>>
>> http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#One-to-many-relation
>>
>> This is the error's traceback:
>>
>> Traceback (most recent call last):
>>   File "/home/gonguinguen/medios/gluon/restricted.py", line 227, in 
>> restricted
>>     exec ccode in environment
>>   File 
>> "/home/gonguinguen/medios/applications/demo_panel/controllers/contenido.py" 
>> <http://localhost/admin/edit/demo_panel/controllers/contenido.py>, line 459, 
>> in <module>
>>   File "/home/gonguinguen/medios/gluon/globals.py", line 412, in <lambda>
>>     self._caller = lambda f: f()
>>   File "/home/gonguinguen/medios/gluon/tools.py", line 3583, in f
>>     return action(*a, **b)
>>   File 
>> "/home/gonguinguen/medios/applications/demo_panel/controllers/contenido.py" 
>> <http://localhost/admin/edit/demo_panel/controllers/contenido.py>, line 436, 
>> in _eliminar_borrador
>>     noticia.galeria_contenido.delete()
>>   File 
>> "/home/gonguinguen/medios/gluon/packages/dal/pydal/helpers/classes.py", line 
>> 348, in __getattr__
>>     raise AttributeError
>> AttributeError
>>
>>
>> The error disappears downgrading to version 2.10.3.
>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to