Hello! Sorry for bad English.
I met the following error:
Traceback (most recent call last):
File
"/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line
255, in __call__
response = self.get_response(request)
File
"/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line
177, in get_response
signals.got_request_exception.send(sender=self.__class__,
request=request)
File
"/usr/local/lib/python2.7/dist-packages/django/dispatch/dispatcher.py",
line 170, in send
response = receiver(signal=self, sender=sender, **named)
File "/usr/local/lib/python2.7/dist-packages/django/db/__init__.py", line
68, in _rollback_on_exception
transaction.rollback_unless_managed(using=conn)
File "/usr/local/lib/python2.7/dist-packages/django/db/transaction.py",
line 143, in rollback_unless_managed
connection.rollback_unless_managed()
File
"/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py",
line 232, in rollback_unless_managed
self._rollback()
File
"/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py",
line 59, in _rollback
return self.connection.rollback()
psycopg2.InterfaceError: connection already closed
The unit of a code where arises an error looks as follows:def
__call__(self, environ, start_response):
# Set up middleware if needed. We couldn't do this earlier, because
# settings weren't available.
if self._request_middleware is None:
with self.initLock:
try:
# Check that middleware is still uninitialised.
if self._request_middleware is None:
self.load_middleware()
except:
# Unload whatever middleware we got
self._request_middleware = None
raise
set_script_prefix(base.get_script_name(environ))
signals.request_started.send(sender=self.__class__)
try:
request = self.request_class(environ)
except UnicodeDecodeError:
logger.warning('Bad Request (UnicodeDecodeError)',
exc_info=sys.exc_info(),
extra={
'status_code': 400,
}
)
response = http.HttpResponseBadRequest()
else:
response =
self.get_response(request)---------------------------------------- the error
arises here
response._handler_class = self.__class__
try:
status_text = STATUS_CODE_TEXT[response.status_code]
except KeyError:
status_text = 'UNKNOWN STATUS CODE'
status = '%s %s' % (response.status_code, status_text)
response_headers = [(str(k), str(v)) for k, v in response.items()]
for c in response.cookies.values():
response_headers.append((str('Set-Cookie'),
str(c.output(header=''))))
start_response(force_str(status), response_headers)
return response
In Django 1.4 it looked:
def __call__(self, environ, start_response):
# Set up middleware if needed. We couldn't do this earlier, because
# settings weren't available.
if self._request_middleware is None:
self.initLock.acquire()
try:
try:
# Check that middleware is still uninitialised.
if self._request_middleware is None:
self.load_middleware()
except:
# Unload whatever middleware we got
self._request_middleware = None
raise
finally:
self.initLock.release()
set_script_prefix(base.get_script_name(environ))
signals.request_started.send(sender=self.__class__)
try:
try:
request = self.request_class(environ)
except UnicodeDecodeError:
logger.warning('Bad Request (UnicodeDecodeError)',
exc_info=sys.exc_info(),
extra={
'status_code': 400,
}
)
response = http.HttpResponseBadRequest()
else:
response = self.get_response(request)
finally:
signals.request_finished.send(sender=self.__class__)
try:
status_text = STATUS_CODE_TEXT[response.status_code]
except KeyError:
status_text = 'UNKNOWN STATUS CODE'
status = '%s %s' % (response.status_code, status_text)
response_headers = [(str(k), str(v)) for k, v in response.items()]
for c in response.cookies.values():
response_headers.append(('Set-Cookie',
str(c.output(header=''))))
start_response(status, response_headers)
return response
That is the unit of a code was in section try...finally(in finnaly signal
was excited signals.request_finished), now it isn't present.
There is a feeling that in case of a code redoing it simply forgot to
consider.
If everything is made intentionally I ask to report about it (if it is
possible the link to documentation)ю
Thanks for attention.
--
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
For more options, visit https://groups.google.com/groups/opt_out.