#10827: django.auth create_permissions must clear the content type cache before creating permissions ----------------------------+----------------------------------------------- Reporter: seanl | Owner: nobody Status: new | Milestone: Component: Authentication | Version: SVN Keywords: | Stage: Unreviewed Has_patch: 0 | ----------------------------+----------------------------------------------- I hit a problem which took some time to track down, where at the DB flush stage in a sequence of tests (using !TransactionTestCase) the recreation of permissions was failing with a FK constraint error.
This was caused by inserting a permission referring to a content type that didn't exist in the DB. This happened because the content type was still in the cache, even thought the django_content_type table had been truncated. The cache hadn't been cleared because post_syncdb signal dispatch had called create_permissions before calling update_contenttypes (which does clear the cache and recreate the content types correctly). The real problem here is that create_permissions and update_contenttypes are both connected to the post_syncdb signal, with the former depending on the latter having been run first, but the dispatcher doesn't guarantee order of dispatch (or rather it dispatches in the order the signal handlers are connected, but that order depends on the order in which modules are loading which is not well-defined). Unfortunately that's a hard problem to solve, and I don't have any ideas about that short of substantive changes to the signal dispatcher. An easier solution to this particular problem is for create_permissions to clear the content types cache before it recreates permissions, that way the necesarry content types will be created as needed (see attached patch). -- Ticket URL: <http://code.djangoproject.com/ticket/10827> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~---
