<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif; ">
<div><span style="font-family: Consolas; font-size: medium; ">Hello,</span></div>
<span id="OLK_SRC_BODY_SECTION">
<div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">
<div style="font-family: Consolas; font-size: medium; "><br>
</div>
<div style="font-family: Consolas; font-size: medium; ">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. </div>
<div style="font-family: Consolas; font-size: medium; "><br>
</div>
<div style="font-family: Consolas; font-size: medium; ">So to fix this issues I actually created a method under the view… Not sure if this will help…</div>
<div style="font-family: Consolas; font-size: medium; "><br>
</div>
<div style="font-family: Consolas; font-size: medium; ">url.py </div>
<div style="font-family: Consolas; font-size: medium; ">urlpatterns = patterns('',</div>
<div style="font-family: Consolas; font-size: medium; "> url(r'^$', IndexView.as_view(), name='index'),</div>
<div style="font-family: Consolas; font-size: medium; "> #others removed</div>
<div style="font-family: Consolas; font-size: medium; ">) </div>
<div style="font-family: Consolas; font-size: medium; "><br>
</div>
<div style="font-family: Consolas; font-size: medium; ">table.py</div>
<div style="font-family: Consolas; font-size: medium; "><br>
</div>
<div style="font-family: Consolas; font-size: medium; ">
<div>class DeleteObj(tables.DeleteAction):</div>
<div> name='deleteObjectNow'</div>
<div> data_type_singular = "Object"</div>
<div> data_type_plural = "Objects"</div>
<div> success_url = reverse_lazy("horizon:admin:foo:index")</div>
</div>
<div style="font-family: Consolas; font-size: medium; "><br>
</div>
<div style="font-family: Consolas; font-size: medium; "><br>
</div>
<div style="font-family: Consolas; font-size: medium; ">view.py</div>
<div style="font-family: Consolas; font-size: medium; ">
<div>class IndexView(tabs.TabView):</div>
<div> tab_group_class = (fooTabs)</div>
<div> template_name = 'admin/foo/index.html'</div>
<div><br>
</div>
<div> def post(self, request, *args, **kwargs):</div>
<div><br>
</div>
<div> try:</div>
<div><span class="Apple-tab-span" style="white-space: pre; "></span> ###lazy :)<span class="Apple-tab-span" style="white-space: pre; ">
</span></div>
<div> foo_id = request.POST['action'].lstrip("device__deleteObjectNow__")</div>
<div> ###Some operation here</div>
<div><br>
</div>
<div> </div>
</div>
<div style="font-family: Consolas; font-size: medium; ">If that does not work you could always do the following.. This was my initial work around… </div>
<div style="font-family: Consolas; font-size: medium; "><br>
</div>
<div style="font-family: Consolas; font-size: medium; ">
<div>class DeleteDevice(tables.Action):</div>
<div> name = "delete"</div>
<div> verbose_name = _("Delete Device")</div>
<div> s_url = 'horizon:admin:foo:index'</div>
<div> </div>
<div> def allowed(self, request, instance):</div>
<div> return True</div>
<div><br>
</div>
<div> def get_default_classes(self):</div>
<div> classes = super(DeleteDevice, self).get_default_classes()</div>
<div> classes += ("btn-danger", "btn-delete")</div>
<div> return classes</div>
<div><br>
</div>
<div><br>
</div>
<div> def single(self, table, request, obj_id):</div>
<div> try:</div>
<div> #Somestuff here</div>
<div><br>
</div>
<div> except:</div>
<div> exceptions.handle(request,</div>
<div> _("can't do this at this time."))</div>
<div> return shortcuts.redirect(self.s_url)</div>
<div><br>
</div>
<div>Hope this helps.. </div>
<div><br>
</div>
<div>Mike</div>
</div>
<div style="font-family: Consolas; font-size: medium; "><br>
</div>
<div style="font-family: Consolas; font-size: medium; ">########################</div>
<div style="font-family: Consolas; font-size: medium; ">Hi Kevin,</div>
<div style="font-family: Consolas; font-size: medium; "><br>
</div>
<div style="font-family: Consolas; font-size: medium; ">"Kevin Benton" <<a href="mailto:blak111@gmail.com">blak111@gmail.com</a>> wrote:</div>
<blockquote id="MAC_OUTLOOK_ATTRIBUTION_BLOCKQUOTE" style="font-family: Consolas; font-size: medium; border-left-color: rgb(181, 196, 223); border-left-width: 5px; border-left-style: solid; padding: 0px 0px 0px 5px; margin: 0px 0px 0px 5px; ">
<div>I'm having some trouble with the tables.DeleteAction class when I'm trying</div>
<div>to add another set of items to a router's detail page.</div>
<div></div>
<div>I found someone emailed the list previously with the exact same problem,</div>
<div>but he never followed up with code or posted a solution. That thread can be</div>
<div>seen here: <a href="https://lists.launchpad.net/openstack/msg18537.html">https://lists.launchpad.net/openstack/msg18537.html</a></div>
<div></div>
<div>Basically, I have the items added to a routers detail page in a separate</div>
<div>table. Elements show up just fine, and I can even add more of them without</div>
<div>issues.</div>
<div></div>
<div>The only problem is with deleting. The links are generated okay, but when</div>
<div>the request is submitted to the server, it never seems to make it to the</div>
<div>"delete" method in the class I have defined so nothing happens. No</div>
<div>exceptions, no log entries, etc.</div>
<div></div>
<div>To demonstrate this in a simple setup, I setup the following branch off of</div>
<div>grizzly/stable that displays this behavior with minimal code changes.</div>
<div>You should be able to check it out, create a router, then click on a router</div>
<div>to get the router details page to see two candy bars listed. If you try to</div>
<div>delete one, you will just get the same page back with no change. The delete</div>
<div>method is just configured to log a message right now, but you can change it</div>
<div>to whatever you want because it never gets called.</div>
<div></div>
<div><a href="https://github.com/blak111/horizon/commit/2a96987a95a9727cd834c7dd31a65e6d8c1efb09">https://github.com/blak111/horizon/commit/2a96987a95a9727cd834c7dd31a65e6d8c1efb09</a></div>
</blockquote>
<div style="font-family: Consolas; font-size: medium; "><br>
</div>
<div style="font-family: Consolas; font-size: medium; ">Thank you for the code sample, that really helps.</div>
<div style="font-family: Consolas; font-size: medium; "><br>
</div>
<div style="font-family: Consolas; font-size: medium; ">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.</div>
<div style="font-family: Consolas; font-size: medium; "><br>
</div>
<div style="font-family: Consolas; font-size: medium; ">Regards,</div>
<div style="font-family: Consolas; font-size: medium; "><br>
</div>
<div style="font-family: Consolas; font-size: medium; ">Julie</div>
<div style="font-family: Consolas; font-size: medium; "><br>
</div>
<blockquote id="MAC_OUTLOOK_ATTRIBUTION_BLOCKQUOTE" style="font-family: Consolas; font-size: medium; border-left-color: rgb(181, 196, 223); border-left-width: 5px; border-left-style: solid; padding: 0px 0px 0px 5px; margin: 0px 0px 0px 5px; ">
<div>Any pointers on how to get the delete request to properly call that method</div>
<div>would be great.</div>
<div></div>
<div>Thanks</div>
<div></div>
<div>--</div>
<div>Kevin Benton</div>
</blockquote>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">
<div class="WordSection1" style="page: WordSection1; "><br class="Apple-interchange-newline">
</div>
</div>
</span>
</body>
</html>