[openstack-dev] class extending tables.DeleteAction not having delete method called

Micheal Thompson MThompson at a10networks.com
Wed Aug 7 07:43:03 UTC 2013


I actually was dealing with a similar problem the other day. After a little debugging… The solution I found was the Post action was begin caught by the view that the url matched.

So to fix this issues I actually created a method under the view… Not sure if this will help…

urlpatterns = patterns('',
    url(r'^$', IndexView.as_view(), name='index'),
    #others removed


class DeleteObj(tables.DeleteAction):
    data_type_singular = "Object"
    data_type_plural = "Objects"
    success_url = reverse_lazy("horizon:admin:foo:index")

class IndexView(tabs.TabView):
    tab_group_class = (fooTabs)
    template_name = 'admin/foo/index.html'

    def post(self, request, *args, **kwargs):

    ###lazy :)
            foo_id = request.POST['action'].lstrip("device__deleteObjectNow__")
            ###Some operation here

If that does not work you could always do the following.. This was my initial work around…

class DeleteDevice(tables.Action):
    name = "delete"
    verbose_name = _("Delete Device")
    s_url = 'horizon:admin:foo:index'

    def allowed(self, request, instance):
       return True

    def get_default_classes(self):
        classes = super(DeleteDevice, self).get_default_classes()
        classes += ("btn-danger", "btn-delete")
        return classes

    def single(self, table, request, obj_id):
            #Somestuff here

                              _("can't do this at this time."))
        return shortcuts.redirect(self.s_url)

Hope this helps..


Hi Kevin,

"Kevin Benton" <blak111 at gmail.com<mailto:blak111 at gmail.com>> wrote:
I'm having some trouble with the tables.DeleteAction class when I'm trying
to add another set of items to a router's detail page.
I found someone emailed the list previously with the exact same problem,
but he never followed up with code or posted a solution. That thread can be
seen here: https://lists.launchpad.net/openstack/msg18537.html
Basically, I have the items added to a routers detail page in a separate
table. Elements show up just fine, and I can even add more of them without
The only problem is with deleting. The links are generated okay, but when
the request is submitted to the server, it never seems to make it to the
"delete" method in the class I have defined so nothing happens. No
exceptions, no log entries, etc.
To demonstrate this in a simple setup, I setup the following branch off of
grizzly/stable that displays this behavior with minimal code changes.
You should be able to check it out, create a router, then click on a router
to get the router details page to see two candy bars listed. If you try to
delete one, you will just get the same page back with no change. The delete
method is just configured to log a message right now, but you can change it
to whatever you want because it never gets called.

Thank you for the code sample, that really helps.

It looks like the id in your get_candybars_data() list needs to be a string for the delete action to work. It's not well (at all?) documented though, so I think it would be fair to submit a bug to update the documentation about this.



Any pointers on how to get the delete request to properly call that method
would be great.
Kevin Benton

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20130807/5adb879e/attachment.html>

More information about the OpenStack-dev mailing list