djangonauts / django-hstore

PostgreSQL HStore support for Django.
http://django-hstore.readthedocs.io/
Other
517 stars 142 forks source link

Additional bootstraping on hstore.py module. #65

Closed niwinz closed 10 years ago

niwinz commented 10 years ago

I have found some strange behavior on get django-hstore working under gunicorn and uwsgi without this patch.

In some strange circumstances, django does not loads django_htore/models.py (using django 1.6.6), it can be a bug of django or some unexpected backward incompatibility. For avoid it, is much better duplicate the hstore bootstrapping code in two major entry points on django hstore for django < 1.7.

And the second commit, is removing now obsolete code. Because the last required psycopg2 version has buitin (and possibly much better) version: http://initd.org/psycopg/docs/extras.html#hstore-data-type

fabiocorneti commented 10 years ago

I think that this pull request may solve issue #47; I tried to debug a request using gunicorn --debug and hstore.models was not imported, so if the first request to a worker was for a view that didn't import hstore.models explicitly Django would raise the ProgrammingError.

If the first request was for a view that did import hstore.models (like the admin index), subsequent requests to the same gunicorn worker would work just fine.

With this patch, gunicorn works as expected for any request.

nemesifier commented 10 years ago

looks like we are getting rid of a bunch of useless code.. :+1: we should definitely try this asap on large scale apps.

niwinz commented 10 years ago

This code not breaks anything, and in my opinion we should merge it and release a bug fix version as sooner posible. With this, we can see if the big problem on issue #47 is solved.

nemesifier commented 10 years ago

ok, go ahead