Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#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'

Subtickets

Change History (7)

comment:1 Changed 5 years ago by ayleph

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.

comment:2 Changed 5 years ago by ayleph

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 Changed 5 years ago by Jessica Tallon

That sounds like the behavior we would want, they should definitely be removed from collections.

comment:4 Changed 5 years ago by ayleph

Priority: majorblocker

Changing priority as the issue reported in this ticket causes crashes and makes a portion of the interface unusable.

comment:5 Changed 5 years ago by Jessica Tallon

Owner: set to Jessica Tallon
Status: newin_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:

  1. Add to the deletion code a check if it's part of any collection and if so have it remove itself.
  2. 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 Changed 5 years ago by Jessica Tallon

Owner: Jessica Tallon deleted
Resolution: fixed
Status: in_progressclosed

This should be fixed as of eedb006. Please pull master and let me know if there is a problem.

comment:7 Changed 5 years ago by Christopher Allan Webber

Milestone: 0.8.20.9.0

All 0.8.2 tickets are being rolled over to 0.9.0

Note: See TracTickets for help on using tickets.