Opened 13 months ago

Closed 13 months ago

Last modified 13 months ago

#22297 closed New feature (fixed)

TransactionMiddleware signals connection_created too early

Reported by: Naddiseo Owned by: nobody
Component: Uncategorized Version: 1.6
Severity: Normal Keywords:
Cc: Naddiseo Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

This may or may not be a django bug.

I have a project that uses django_hstore, which relies on connection_created in order to register the database adapters for hstore conversion with postgresql. With TransactionMiddleware the signal seems to be called before all the INSTALLED_APPS are loaded, thus it is called before django_hstore is loaded.

I am able to reproduce this issue with
python 2.7.5
django 1.6.2
django-hstore 1.2.2
uwsgi 2.0.3
psycopg2 2.5.2

Unfortunately, it can't be reproduced with manage.py runserver because it validates the models, which loads the apps before the signal is called.

I've attached a test project with the following setup:

  • Create a postgres database named hstore_test_db with user/password as test/test
  • Run syncdb
  • Run manage.py shell
  • from main.models import TestModel; TestModel.objects.create(dict_field= {'key' : 1 })
  • Run uwsgi with the following settings:

uwsgi --http :8000 --module hstore_test.wsgi --chdir $(pwd) --home $VIRTUAL_ENV --e DJANGO_SETTINGS_MODULE=hstore_test.settings

Note: the error only occurs on the first page load after starting uwsgi. It fails to error on any subsequent refresh.

Attachments (1)

hstore_test.tar.gz (3.6 KB) - added by Naddiseo 13 months ago.
Test Project

Download all attachments as: .zip

Change History (3)

Changed 13 months ago by Naddiseo

Test Project

comment:1 Changed 13 months ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to fixed
  • Status changed from new to closed

This will be fixed by app-loading in 1.7 ;-)

Look for the wall of text on the DevelopersMailingList for details.

comment:2 Changed 13 months ago by Naddiseo

  • Cc Naddiseo added
Note: See TracTickets for help on using tickets.
Back to Top