nasa-jpl-memex / memex-explorer

Viewers for statistics and dashboarding of Domain Search Engine data
BSD 2-Clause "Simplified" License
121 stars 69 forks source link

Cannot delete some instances of model CrawlModel #738

Closed ahmadia closed 8 years ago

ahmadia commented 8 years ago

Encountered after trying to delete a project that contains references to crawlmodels used by another project.

Brittain, this seems like an internal error that we're triggering from the way we've structured our models. What do you think?

Environment:

Request Method: POST
Request URL: http://localhost:8000/projects/wikipedia-crawl-with-nutch/settings/delete/

Django Version: 1.7.3
Python Version: 2.7.8
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'crispy_forms',
 'base',
 'task_manager',
 'rest_framework',
 'apps.crawl_space',
 'debug_toolbar')
Installed Middleware:
(u'debug_toolbar.middleware.DebugToolbarMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')

Traceback:
File "/Users/aahmadia/anaconda/envs/memex/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  111.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/aahmadia/anaconda/envs/memex/lib/python2.7/site-packages/django/views/generic/base.py" in view
  69.             return self.dispatch(request, *args, **kwargs)
File "/Users/aahmadia/anaconda/envs/memex/lib/python2.7/site-packages/django/views/generic/base.py" in dispatch
  87.         return handler(request, *args, **kwargs)
File "/Users/aahmadia/anaconda/envs/memex/lib/python2.7/site-packages/django/views/generic/edit.py" in post
  259.         return self.delete(request, *args, **kwargs)
File "/Users/aahmadia/memex-explorer/source/base/views.py" in delete
  153.         return super(DeleteProjectView, self).delete(request, *args, **kwargs)
File "/Users/aahmadia/anaconda/envs/memex/lib/python2.7/site-packages/django/views/generic/edit.py" in delete
  254.         self.object.delete()
File "/Users/aahmadia/anaconda/envs/memex/lib/python2.7/site-packages/django/db/models/base.py" in delete
  738.         collector.collect([self])
File "/Users/aahmadia/anaconda/envs/memex/lib/python2.7/site-packages/django/db/models/deletion.py" in collect
  199.                     field.rel.on_delete(self, field, sub_objs, self.using)
File "/Users/aahmadia/anaconda/envs/memex/lib/python2.7/site-packages/django/db/models/deletion.py" in CASCADE
  17.                       source_attr=field.name, nullable=field.null)
File "/Users/aahmadia/anaconda/envs/memex/lib/python2.7/site-packages/django/db/models/deletion.py" in collect
  199.                     field.rel.on_delete(self, field, sub_objs, self.using)
File "/Users/aahmadia/anaconda/envs/memex/lib/python2.7/site-packages/django/db/models/deletion.py" in PROTECT
  27.         sub_objs

Exception Type: ProtectedError at /projects/wikipedia-crawl-with-nutch/settings/delete/
Exception Value: ("Cannot delete some instances of model 'CrawlModel' because they are referenced through a protected foreign key: 'Crawl.crawl_model'", [<Crawl: c11>])
ProtectedError at /projects/wikipedia-crawl-with-nutch/settings/delete/
("Cannot delete some instances of model 'CrawlModel' because they are referenced through a protected foreign key: 'Crawl.crawl_model'", [<Crawl: c11>])
Request Method: POST
Request URL:    http://localhost:8000/projects/wikipedia-crawl-with-nutch/settings/delete/
Django Version: 1.7.3
Exception Type: ProtectedError
Exception Value:    
("Cannot delete some instances of model 'CrawlModel' because they are referenced through a protected foreign key: 'Crawl.crawl_model'", [<Crawl: c11>])
Exception Location: /Users/aahmadia/anaconda/envs/memex/lib/python2.7/site-packages/django/db/models/deletion.py in PROTECT, line 27
Python Executable:  /Users/aahmadia/anaconda/envs/memex/bin/python
Python Version: 2.7.8
Python Path:    
['/Users/aahmadia/memex-explorer/source',
 '/Users/aahmadia/memex-explorer/source',
 '/Users/aahmadia/memex-explorer/source',
 '/Users/aahmadia/nutch/nutch-python',
 '/Users/aahmadia/anaconda/envs/memex/lib/python27.zip',
 '/Users/aahmadia/anaconda/envs/memex/lib/python2.7',
 '/Users/aahmadia/anaconda/envs/memex/lib/python2.7/plat-darwin',
 '/Users/aahmadia/anaconda/envs/memex/lib/python2.7/plat-mac',
 '/Users/aahmadia/anaconda/envs/memex/lib/python2.7/plat-mac/lib-scriptpackages',
 '/Users/aahmadia/anaconda/envs/memex/lib/python2.7/lib-tk',
 '/Users/aahmadia/anaconda/envs/memex/lib/python2.7/lib-old',
 '/Users/aahmadia/anaconda/envs/memex/lib/python2.7/lib-dynload',
 '/Users/aahmadia/anaconda/envs/memex/lib/python2.7/site-packages/Sphinx-1.2.3-py2.7.egg',
 '/Users/aahmadia/anaconda/envs/memex/lib/python2.7/site-packages/gunicorn-19.1.0-py2.7.egg',
 '/Users/aahmadia/anaconda/envs/memex/lib/python2.7/site-packages/pytest_runner-2.6.2-py2.7.egg',
 '/Users/aahmadia/anaconda/envs/memex/lib/python2.7/site-packages/setuptools-18.4-py2.7.egg',
 '/Users/aahmadia/anaconda/envs/memex/lib/python2.7/site-packages',
 '/Users/aahmadia/anaconda/envs/memex/lib/python2.7/site-packages/elasticsearch-1.6.0-py2.7.egg',
 '/Users/aahmadia/anaconda/envs/memex/lib/python2.7/site-packages/nutch-1.10.3-py2.7.egg',
 '/Users/aahmadia/anaconda/envs/memex/lib/python2.7/site-packages/urllib3-1.11-py2.7.egg',
 '/Users/aahmadia/memex-explorer/source']
Server time:    Wed, 28 Oct 2015 15:21:17 +0000
ahmadia commented 8 years ago

Brittain, I'd like you to look at this one before we tag.

brittainhard commented 8 years ago

Yeah, you cant delete a crawl model because a crawl is currently using it. This is a big. I will try to fix this quickly.