linuxlewis / djorm-ext-pgfulltext

PostgreSQL full-text search integration with django orm.
Other
250 stars 84 forks source link

Exception Value: must be psycopg2.extensions.connection, not None #78

Open troygrosfield opened 8 years ago

troygrosfield commented 8 years ago

Getting an error with passing a connection == None with the latest in the master branch.

Traceback:

File "/python3.4/site-packages/django/core/handlers/base.py" in get_response
  149.                     response = self.process_exception_by_middleware(e, request)
File "/python3.4/site-packages/django/core/handlers/base.py" in get_response
  147.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/python3.4/site-packages/django/views/generic/base.py" in view
  68.             return self.dispatch(request, *args, **kwargs)
File "/python3.4/site-packages/django_core/views/mixins/paging.py" in dispatch
  27.         return super(PagingViewMixin, self).dispatch(*args, **kwargs)
File "/python3.4/site-packages/django/views/generic/base.py" in dispatch
  88.         return handler(request, *args, **kwargs)
File "/webapps/mm/app/search/views.py" in get
  27.             return self.form_valid(form=self.form)
File "/webapps/mm/app/search/views.py" in form_valid
  40.         return ListView.get(self, request=self.request)
File "/python3.4/site-packages/django/views/generic/list.py" in get
  159.         self.object_list = self.get_queryset()
File "/webapps/mm/app/search/views.py" in get_queryset
  87.                 **self.get_search_kwargs()
File "/webapps/mm/app/search/managers.py" in search
  38.                 headline_document=headline_document
File "/python3.4/site-packages/djorm_pgfulltext/models.py" in search
  129.         return self.get_queryset().search(*args, **kwargs)
File "/python3.4/site-packages/djorm_pgfulltext/models.py" in search
  315.                 "%s('%s', %s)" % (function, config, adapt(query))
File "/python3.4/site-packages/djorm_pgfulltext/utils.py" in adapt
  9.     a.prepare(connection.connection)

Exception Type: TypeError at /search
Exception Value: must be psycopg2.extensions.connection, not None
chrismarlow9 commented 8 years ago

This was blocking production for me so I created a quick hack here:

https://github.com/chrismarlow9/djorm-ext-pgfulltext

Not sure if it's the proper solution (I don't know much around the connection pooling of psycopg2 or its internals, just a bare bones connection). Warning: use at your own risk in production, but it's working fine for me so far.