#5382 closed defect (fixed)
Graveyard media in collection give server error
| Reported by: | ayleph | Owned by: | |
|---|---|---|---|
| Priority: | blocker | Milestone: | 0.9.0 |
| Component: | programming | Keywords: | graveyard |
| Cc: | tsyesika | Parent Tickets: |
Description
I'm seeing server errors in my logs when someone tries to access a collection which has Graveyarded media.
Error - <class 'jinja2.exceptions.UndefinedError'>: 'mediagoblin.db.models.Graveyard object' has no attribute 'url_for_self'
File '/path/to/mediagoblin/lib/python2.7/site-packages/paste/exceptions/errormiddleware.py', line 144 in __call__
app_iter = self.application(environ, sr_checker)
File '/path/to/mediagoblin/mediagoblin/app.py', line 342 in __call__
return self.call_backend(environ, start_response)
File '/path/to/mediagoblin/lib/python2.7/site-packages/Werkzeug-0.10.1-py2.7.egg/werkzeug/wsgi.py', line 591 in __call__
return self.app(environ, start_response)
File '/path/to/mediagoblin/mediagoblin/app.py', line 276 in call_backend
return self._finish_call_backend(request, environ, start_response)
File '/path/to/mediagoblin/mediagoblin/app.py', line 318 in _finish_call_backend
response = controller(request)
File '/path/to/mediagoblin/mediagoblin/decorators.py', line 47 in wrapper
return controller(request, *args, **kwargs)
File '/path/to/mediagoblin/mediagoblin/decorators.py', line 119 in wrapper
return controller(request, *args, url_user=user, **kwargs)
File '/path/to/mediagoblin/mediagoblin/decorators.py', line 170 in wrapper
return controller(request, page=page, *args, **kwargs)
File '/path/to/mediagoblin/mediagoblin/user_pages/views.py', line 396 in user_collection
'pagination': pagination})
File '/path/to/mediagoblin/mediagoblin/tools/response.py', line 36 in render_to_response
render_template(request, template, context),
File '/path/to/mediagoblin/mediagoblin/tools/template.py', line 144 in render_template
rendered = template.render(context)
File '/path/to/mediagoblin/lib/python2.7/site-packages/Jinja2-2.7.3-py2.7.egg/jinja2/environment.py', line 969 in render
return self.environment.handle_exception(exc_info, True)
File '/path/to/mediagoblin/lib/python2.7/site-packages/Jinja2-2.7.3-py2.7.egg/jinja2/environment.py', line 742 in handle_exception
reraise(exc_type, exc_value, tb)
File '/path/to/mediagoblin/mediagoblin/templates/mediagoblin/user_pages/collection.html', line 20 in top-level template code
{% from "mediagoblin/utils/collection_gallery.html" import collection_gallery %}
File '/var/lib/mediagoblin/templates/mediagoblin/base.html', line 64 in top-level template code
{% block mediagoblin_body %}
File '/var/lib/mediagoblin/templates/mediagoblin/base.html', line 203 in block "mediagoblin_body"
{% block mediagoblin_content %}
File '/path/to/mediagoblin/mediagoblin/templates/mediagoblin/user_pages/collection.html', line 65 in block "mediagoblin_content"
{{ collection_gallery(request, collection_items, pagination) }}
File '/path/to/mediagoblin/mediagoblin/templates/mediagoblin/utils/collection_gallery.html', line 73 in template
{{ media_grid(request, collection_items, col_number=col_number) }}
File '/path/to/mediagoblin/mediagoblin/templates/mediagoblin/utils/collection_gallery.html', line 29 in template
{% set obj_url = obj.url_for_self(request.urlgen) %}
UndefinedError: 'mediagoblin.db.models.Graveyard object' has no attribute 'url_for_self'
Change History (7)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
I can confirm that deleted media still exist in core__collection_items. Removing media from this table prevents them from being loaded in the collection view, thereby preventing this issue. I propose that soft-deleting media should also remove that media from any collections to which it had added.
comment:3 by , 10 years ago
That sounds like the behavior we would want, they should definitely be removed from collections.
comment:4 by , 10 years ago
| Priority: | major → blocker |
|---|
Changing priority as the issue reported in this ticket causes crashes and makes a portion of the interface unusable.
comment:5 by , 10 years ago
| Owner: | set to |
|---|---|
| Status: | new → in_progress |
I was waiting on #814 to be closed as this will require a migration. That happened yesterday so I'm going to go ahead and create a fix for this today. My plan is to do two things to fix this:
- Add to the deletion code a check if it's part of any collection and if so have it remove itself.
- Create a migration to do this check on all graveyard object and if so remove it to fix those that have been deleted before this fix.
comment:6 by , 10 years ago
| Owner: | removed |
|---|---|
| Resolution: | → fixed |
| Status: | in_progress → closed |
This should be fixed as of eedb006. Please pull master and let me know if there is a problem.
comment:7 by , 10 years ago
| Milestone: | 0.8.2 → 0.9.0 |
|---|
All 0.8.2 tickets are being rolled over to 0.9.0

The surrounding code in collection_gallery.html looks like this.
... {% for row in collection_items|batch(col_number) %} <div class="row thumb_row {%- if loop.first %} thumb_row_first {%- elif loop.last %} thumb_row_last{% endif %}"> {% for item in row %} {% set obj = item.get_object() %} {% set obj_url = obj.url_for_self(request.urlgen) %} ...Perhaps media should be removed from a collection when soft deleted so they don't show up as a row in
collection_items.