Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Django + Reversion broken on Windows 7 #84

Closed
gdonald opened this Issue · 4 comments

2 participants

@gdonald

I have a Django project I usually develop on Linux. Now I have to debug some IE9 issues. So I setup my Django project on Windows.

manage.py runserver runs but every url I try crashes like below:

Traceback (most recent call last):

File "c:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 283, in run
self.result = application(self.environ, self.start_response)

File "c:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", line 68, in call
return self.application(environ, start_response)

File "c:\Python27\lib\site-packages\django\core\handlers\wsgi.py", line 274, in call
signals.request_finished.send(sender=self.class)

File "c:\Python27\lib\site-packages\django\dispatch\dispatcher.py", line 172, in send
response = receiver(signal=self, sender=sender, **named)

File "c:\Python27\lib\site-packages\reversion\revisions.py", line 242, in _request_finished_receiver
"Request finished with an open revision. All calls to revision.start() "

RevisionManagementError: Request finished with an open revision. All calls to revision.start() should be balanced by a call to revision.end().

The particular URL this trace is for doesn't even use Reversion. No idea why it'd even be starting a new revision.

I'm using Django 1.3.1, Python 2.7, Win7 64, PostgreSQL 9.1.

Any idea how to fix? Thanks.

@etianen
Owner

That's really, really odd.

The error is being caused because, as a sanity check, reversion throws an error if there is an open revision at the end of a request. This is because it would utterly destroy the reversion backend if calls to reversion.revision.start() were left hanging without a corresponding call to reversion.revision.end().

This really needs debugging. I'd to it myself, but I don't have a windows box at the moment that can be conveniently pythonified. Here's some starters:

  1. Are you making a call to reversion.revision.start() ANYWHERE in your codebase?
  2. Are you using the RevisionMiddleware?
@gdonald

1) I don't believe so:

grep -ir 'revision' /py
contact_phones/views.py:from reversion import revision
contact_phones/views.py: version.revision.comment = 'Reverted'
contact_phones/views.py: version.revision.save()
contact_phones/views.py: if version.revision.user_id not in user_ids:
contact_phones/views.py: messages.info( request, 'Not your revision' )
contact_phones/views.py: version.revision.revert()
contact_phones/views.py:@revision.create_on_success
contact_phones/views.py: revision.comment = 'Created via the web'
contact_phones/views.py:@revision.create_on_success
contact_phones/views.py: revision.comment = 'Updated via the web'
contact_phones/views.py:@revision.create_on_success
contact_phones/views.py: revision.comment = 'Deleted via the web'
contacts/views.py:from reversion import revision
contacts/views.py: if version.revision.user_id not in user_ids:
contacts/views.py: messages.info( request, 'Not your revision' )
contacts/views.py: version.revision.revert()
contacts/views.py: version.revision.comment = 'Undeleted'
contacts/views.py: version.revision.save()
contacts/views.py: version.revision.comment = 'Reverted'
contacts/views.py: version.revision.save()
contacts/views.py: if version.revision.user_id not in user_ids:
contacts/views.py: messages.info( request, 'Not your revision' )
contacts/views.py: version.revision.revert()
contacts/views.py:@revision.create_on_success
contacts/views.py: revision.comment = 'Added via the web'
contacts/views.py:@revision.create_on_success
contacts/views.py: revision.comment = 'Updated via the web'
contacts/views.py:@revision.create_on_success
contacts/views.py: revision.comment = 'Deleted via the web'
contacts/views.py:@revision.create_on_success
contacts/views.py: revision.comment = 'Imported via the web'

2) Yes, my middleware setup is like this:

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.transaction.TransactionMiddleware',
'reversion.middleware.RevisionMiddleware',
'cp.middleware.ViewName',
'cp.middleware.GetCompany'
)

Thanks for the speedy response.

@etianen
Owner

If you take out the RevisionMiddleware, does the problem go away? That's the only place where the begin() and end() calls are guaranteed to be paired by language features.

@etianen
Owner

Because it looks like there's a few other server setups that are apparently breaking the Django middleware protocol, I've removed the error that raised, and am now just closing the revision.

@etianen etianen closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.