I read more about "Foreign Key constraint" in sqlite docs (Should have done this in the begining).
The error cause is there is a reference key to the auth.user in another table. So sqlite cannot delete the user without "ON DELETE CASCADE". Is there any place I can config "on delete cascade" or I just find a new bug? :) Best, Yi On Monday, January 25, 2016 at 8:59:17 AM UTC-8, Massimo Di Pierro wrote: > > Do you still get the ticket if you remove the logic for the additional > form on the profile page? > > On Sunday, 24 January 2016 21:11:33 UTC-6, Yi Liu wrote: >> >> Dear fellow w2p users, >> >> First, thank you so much for providing this great app Web2Py for *free*. >> >> Recently I updated my app to allow user to delete account themselves. >> >> auth.settings.allow_delete_accounts= True >> >> >> Today, I received feedback from user that that function is broken on my >> site. >> >> Then I realize there is a ticket when that function is called. >> >> <class 'sqlite3.IntegrityError'> FOREIGN KEY constraint failed >> Version >> web2py™ Version 2.13.4-stable+timestamp.2015.12.26.04.59.39 >> Python Python 2.7.11: >> /home/liuyidh/.pyenv/versions/miniconda-3.16.0/bin/python (prefix: >> /home/liuyidh/.pyenv/versions/miniconda-3.16.0) >> Traceback >> >> 1. >> 2. >> 3. >> 4. >> 5. >> 6. >> 7. >> 8. >> 9. >> 10. >> 11. >> 12. >> 13. >> 14. >> 15. >> 16. >> 17. >> 18. >> 19. >> 20. >> >> Traceback (most recent call last): >> File "/home/liuyidh/lovelovebean.com/gluon/restricted.py", line 227, in >> restricted >> exec ccode in environment >> File >> "/home/liuyidh/lovelovebean.com/applications/LLBean/controllers/default.py" >> <http://127.0.0.1:8001/admin/edit/LLBean/controllers/default.py>, line 97, >> in <module> >> File "/home/liuyidh/lovelovebean.com/gluon/globals.py", line 412, in >> <lambda> >> self._caller = lambda f: f() >> File >> "/home/liuyidh/lovelovebean.com/applications/LLBean/controllers/default.py" >> <http://127.0.0.1:8001/admin/edit/LLBean/controllers/default.py>, line 55, >> in user >> return dict(form=auth(), formFil=formFil) >> File "/home/liuyidh/lovelovebean.com/gluon/tools.py", line 1923, in >> __call__ >> return getattr(self, args[0])() >> File "/home/liuyidh/lovelovebean.com/gluon/tools.py", line 4025, in profile >> self.log_event(log, self.user) >> File "/home/liuyidh/lovelovebean.com/gluon/tools.py", line 2521, in >> log_event >> origin=origin, user_id=user_id) >> File "/home/liuyidh/lovelovebean.com/gluon/packages/dal/pydal/objects.py", >> line 731, in insert >> ret = self._db._adapter.insert(self, self._listify(fields)) >> File >> "/home/liuyidh/lovelovebean.com/gluon/packages/dal/pydal/adapters/base.py", >> line 746, in insert >> raise e >> IntegrityError: FOREIGN KEY constraint failed >> >> >> >> I searched stackoverflow for tips. It seems the causes are different. >> Some are due to migration, some due to wrong reference, others due to >> auth(). >> >> I have a user form in the profile page: >> >> def user(): >> if request.args(0)=='profile': >> db.auth_criteria.user_id.default = auth.user_id >> record = db.auth_criteria(db.auth_criteria.user_id==auth.user_id) >> formFil=SQLFORM(db.auth_criteria, >> record=record, >> labels = {'salePrice':XML('<h3>TWO-A-DAY Clothing & Home >> Goods</h3> (By Sale Price)'), >> 'tgPrice':XML('<h3>ONE-A-DAY Travel and Gear </h3> >> (By Sale Price)'), >> 'aveRev':XML('<b>By Avereage Ratings</b>'), >> 'percSave':XML('<b>By Percentage Saved</b>'), >> 'genderPref':XML('<h3>By Gender of Products</h3> >> AND-gate. Other filters apply') >> }, >> buttons = [TAG.button('Set Mine', _class='btn-primary')]) >> if formFil.process().accepted: >> response.flash = XML('Your preference is recorded. <br>Get >> ready for lovely beans.') >> return dict(form=auth(), formFil=formFil) >> else: >> return dict(form=auth()) >> >> I have a custom defined table: >> >> db.define_table('auth_criteria', >> Field <http://127.0.0.1:8001/examples/global/vars/Field>('user_id', >> 'reference auth_user', readable=False, writable=False), >> Field <http://127.0.0.1:8001/examples/global/vars/Field>('salePrice', >> 'integer', widget=SQLFORM >> <http://127.0.0.1:8001/examples/global/vars/SQLFORM>.widgets.radio.widget, >> requires = IS_IN_SET >> <http://127.0.0.1:8001/examples/global/vars/IS_IN_SET>(salePrice)), >> Field <http://127.0.0.1:8001/examples/global/vars/Field>('tgPrice', >> 'integer', widget=SQLFORM >> <http://127.0.0.1:8001/examples/global/vars/SQLFORM>.widgets.radio.widget, >> requires = IS_IN_SET >> <http://127.0.0.1:8001/examples/global/vars/IS_IN_SET>(tgPrice)), >> Field <http://127.0.0.1:8001/examples/global/vars/Field>('aveRev', >> 'integer', requires = IS_IN_SET >> <http://127.0.0.1:8001/examples/global/vars/IS_IN_SET>(aveRev)), >> Field <http://127.0.0.1:8001/examples/global/vars/Field>('percSave', >> 'integer', requires = IS_IN_SET >> <http://127.0.0.1:8001/examples/global/vars/IS_IN_SET>(percSave)), >> >> ... > > -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.