Opened 9 years ago
Closed 9 years ago
#5421 closed defect (cant-reproduce)
Server error when trying to access atom feed with graveyard media
Reported by: | ayleph | Owned by: | |
---|---|---|---|
Priority: | blocker | Milestone: | 0.9.0 |
Component: | programming | Keywords: | graveyard, feed |
Cc: | tsyesika | Parent Tickets: |
Description
Attempting to access a collection's atom feed causes an error when that feed contains graveyard items.
Error - <type 'exceptions.AttributeError'>: 'Graveyard' object has no attribute 'title' URL: https://goblinrefuge.com/mediagoblin/u/topo/collection/free-culture/atom/ File '/path/to/mediagoblin/lib/python2.7/site-packages/Paste-1.7.5.1-py2.7.egg/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/user_pages/views.py', line 621 in collection_atom_feed obj.get('title'), File '/path/to/mediagoblin/mediagoblin/db/base.py', line 72 in get return getattr(self, key) AttributeError: 'Graveyard' object has no attribute 'title'
Change History (5)
comment:1 by , 9 years ago
comment:2 by , 9 years ago
Cc: | added |
---|
comment:3 by , 9 years ago
I'm trying to replicate this, but I'm having trouble. There may be more to it than simply deleting media attached to a collection. I'll continue to dig.
comment:4 by , 9 years ago
Owner: | set to |
---|---|
Status: | new → in_progress |
I'll try to reproduce and see if I can.
comment:5 by , 9 years ago
Owner: | removed |
---|---|
Resolution: | → worksforme |
Status: | in_progress → closed |
Okay, I'm not able to reproduce this, what I've tried is:
- Create a collection
- Upload media to said collection
- Verify the media is in the atom feet.
- Delete the media in the collection
- Check the atom feed is empty.
This works as expected. I then decided I'd dig in and find out how CollectionItem were deleted (I had forgotten what I had done). The code to delete them is
def delete(self, commit=True, deletion=None): """ Delete the object either using soft or hard deletion """ # Get the setting in the model args if none has been specified. if deletion is None: deletion = self.deletion_mode # If the item is in any collection then it should be removed, this will # cause issues if it isn't. See #5382. # Import here to prevent cyclic imports. from mediagoblin.db.models import CollectionItem, GenericModelReference, \ Report, Notification # Some of the models don't have an "id" field which means they can't be # used with GMR, these models won't be in collections because they # can't be. We can skip all of this. if hasattr(self, "id"): # First find the GenericModelReference for this object gmr = GenericModelReference.query.filter_by( obj_pk=self.id, model_type=self.__tablename__ ).first() # If there is no gmr then we've got lucky, a GMR is a requirement of # being in a collection. if gmr is not None: # Delete collections found items = CollectionItem.query.filter_by( object_id=gmr.id ) items.delete()
This is located on the GMGTableBase
so it's run when the delete
method is run on the media entry. This queries for all the collection items which point to the media and then delete them. I'm going to close this as cannot reproduce but I'm curious what issue you're having. If you can give me more information on how to reproduce this please do re-open it.
It looks like this issue occurs because
soft_delete
doesn't remove CollectionItems. Frommediagoblin/db/models.py
, we see thatdelete
has a note about deleting CollectionItems with cascade, but that doesn't happen with soft_delete.I think this needs two courses of action.
soft_delete
to remove CollectionItems.