Delete file triggers 'CommunityFile' object has no attribute '__parent__'

Bug #1045483 reported by JimPGlenn
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
KARL3
Fix Released
High
JimPGlenn

Bug Description

There are two deletes for files the delete button at the individual file ends in a general error see screencast.

I found this in the error monitor:

AttributeError: 'CommunityFile' object has no attribute '__parent__'
Exception when processing https://karl.soros.org/communities/tester/files/testsearch.docx/delete.html?confirm=1
Referer: https://karl.soros.org/communities/tester/files/testsearch.docx/delete.html

Traceback (most recent call last):
  File "/srv/osfkarl/production/4/eggs/pyramid-1.2.1-py2.6.egg/pyramid/tweens.py", line 17, in excview_tween
    response = handler(request)
  File "/srv/osfkarl/production/4/eggs/pyramid_tm-0.5-py2.6.egg/pyramid_tm/__init__.py", line 107, in tm_tween
    return response
  File "/srv/osfkarl/production/4/eggs/pyramid_tm-0.5-py2.6.egg/pyramid_tm/__init__.py", line 75, in __exit__
    return self._retry_or_raise(t, v, tb)
  File "/srv/osfkarl/production/4/eggs/pyramid_tm-0.5-py2.6.egg/pyramid_tm/__init__.py", line 60, in _retry_or_raise
    reraise(t, v, tb) # otherwise reraise the exception
  File "/srv/osfkarl/production/4/eggs/pyramid_tm-0.5-py2.6.egg/pyramid_tm/__init__.py", line 100, in tm_tween
    response = handler(request)
  File "/srv/osfkarl/production/4/eggs/pyramid-1.2.1-py2.6.egg/pyramid/router.py", line 153, in handle_request
    response = view_callable(context, request)
  File "/srv/osfkarl/production/4/eggs/pyramid-1.2.1-py2.6.egg/pyramid/config/views.py", line 186, in _secured_view
    return view(context, request)
  File "/srv/osfkarl/production/4/eggs/pyramid-1.2.1-py2.6.egg/pyramid/config/views.py", line 292, in rendered_view
    result = view(context, request)
  File "/srv/osfkarl/production/4/eggs/karl-3.93-py2.6.egg/karl/views/resource.py", line 39, in delete_resource_view
    del context.__parent__[context.__name__]
  File "/srv/osfkarl/production/4/eggs/repoze.folder-0.6.2-py2.6.egg/repoze/folder/__init__.py", line 151, in __delitem__
    return self.remove(name)
  File "/srv/osfkarl/production/4/eggs/repoze.folder-0.6.2-py2.6.egg/repoze/folder/__init__.py", line 180, in remove
    objectEventNotify(ObjectRemovedEvent(other, self, name))
  File "/srv/osfkarl/production/4/eggs/zope.component-3.6.0-py2.6.egg/zope/component/event.py", line 33, in objectEventNotify
    adapters = zope.component.subscribers((event.object, event), None)
  File "/srv/osfkarl/production/4/eggs/zope.component-3.6.0-py2.6.egg/zope/component/_api.py", line 138, in subscribers
    return sitemanager.subscribers(objects, interface)
  File "/srv/osfkarl/production/4/eggs/zope.component-3.6.0-py2.6.egg/zope/component/registry.py", line 315, in subscribers
    return self.adapters.subscribers(objects, provided)
  File "/srv/osfkarl/production/4/eggs/zope.interface-3.5.1-py2.6-linux-i686.egg/zope/interface/adapter.py", line 535, in subscribers
    subscription(*objects)
  File "/srv/osfkarl/production/4/eggs/karl-3.93-py2.6.egg/karl/models/subscribers.py", line 222, in delete_in_repo
    user = authenticated_userid(request)
  File "/srv/osfkarl/production/4/eggs/pyramid-1.2.1-py2.6.egg/pyramid/security.py", line 67, in authenticated_userid
    return policy.authenticated_userid(request)
  File "/srv/osfkarl/production/4/eggs/pyramid_multiauth-0.1.2-py2.6.egg/pyramid_multiauth/__init__.py", line 55, in authenticated_userid
    userid = policy.authenticated_userid(request)
  File "/srv/osfkarl/production/4/eggs/pyramid-1.2.1-py2.6.egg/pyramid/authentication.py", line 48, in authenticated_userid
    callback_ok = self.callback(userid, request)
  File "/srv/osfkarl/production/4/eggs/karl-3.93-py2.6.egg/karl/application.py", line 93, in group_finder
    users = find_users(request.context)
  File "/srv/osfkarl/production/4/eggs/karl-3.93-py2.6.egg/karl/utils.py", line 49, in find_users
    return getattr(find_site(context), 'users', None)
  File "/srv/osfkarl/production/4/eggs/karl-3.93-py2.6.egg/karl/utils.py", line 45, in find_site
    site = find_root(context)
  File "/srv/osfkarl/production/4/eggs/pyramid-1.2.1-py2.6.egg/pyramid/traversal.py", line 26, in find_root
    if location.__parent__ is None:
AttributeError: 'CommunityFile' object has no attribute '__parent__'

Revision history for this message
JimPGlenn (jpglenn09) wrote :

screencast

Revision history for this message
Paul Everitt (paul-agendaless) wrote :

Carlos, I haven't looked to see if I can recreate this locally.

Changed in karl3:
assignee: nobody → Carlos de la Guardia (cguardia)
importance: Undecided → High
milestone: none → m117
description: updated
summary: - Delete files not working
+ Delete file triggers 'CommunityFile' object has no attribute
+ '__parent__'
Revision history for this message
Carlos de la Guardia (cguardia) wrote :

The new group finder tried to traverse the file objects, which are not traversable (no __parent__). Added condition to avoid this and pushed to cguardia-delete-file.

Changed in karl3:
status: New → Fix Committed
Changed in karl3:
assignee: Carlos de la Guardia (cguardia) → Chris Rossi (chris-archimedeanco)
Revision history for this message
Chris Rossi (chris-archimedeanco) wrote :

Carlos's fix didn't look right to me so I tested locally and got the exact same problem. The real issue here is that Repozitory is trying to get a user's identity by traversing to root.users from the current context, which, unfortunately, has been detached from the tree because it's just been deleted. This also causes errors found in the error monitor when users attempt to delete wiki pages.

I have committed a different fix to the 'fix-delete' branch. Both file and wiki page deletion should be tested on this branch.

Revision history for this message
Paul Everitt (paul-agendaless) wrote :

Jim, can you test this on karldev fix-delete branch? See if this and the "can't search for ozarkia" issue have been fixed.

Changed in karl3:
assignee: Chris Rossi (chris-archimedeanco) → JimPGlenn (jpglenn09)
Revision history for this message
JimPGlenn (jpglenn09) wrote :

fix_delete branch worked perfect for search and for delete.

tags: added: search tested
JimPGlenn (jpglenn09)
tags: added: r3.94
Revision history for this message
JimPGlenn (jpglenn09) wrote :

fixed

Changed in karl3:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.