def admin_unreg_fs(request):
    profile = UserProfile.get_or_create_profile(request.user)
    if (not profile.is_net_admin):
        return HttpResponseRedirect("/dashboard")
    
    # the first admin can't give up the "all" flowspace he/she owns
    if profile.supervisor == profile.user:
        return HttpResponseRedirect("/dashboard")
    
    error_msg = []
    if (request.method == "POST"):
        fs_changed = False
        for key in request.POST:
            verified = re.match(r"verif_(?P<id>\d+)",key)
            pending = re.match(r"pend_(?P<id>\d+)",key)
            try:
                status = 0
                if (verified):
                    key_id = verified.group("id")
                    status = 1
                elif (pending):
                    key_id =pending.group("id")
                    status = 2
            except:
                continue
            if (status == 1):
                fs_changed = True
                try:
                    AdminFlowSpace.objects.get(id=int(key_id)).delete()
                except:
                    error_msg.append("Invalid id(%s) found in the request.POST for admin flowspace."%key_id)
            elif (status == 2):
                try:
                    RequestedAdminFlowSpace.objects.get(id=int(key_id)).delete()
                except:
                    error_msg.append("Invalid id(%s) found in the request.POST for admin pending flowspace."%key_id)

        if fs_changed:
            fv_args = update_admin_opts(request.user)
            try:
                fv = FVServerProxy.objects.all()[0]
                try:
                    if len(fv_args) > 0:
                        fv.proxy.api.changeFlowSpace(fv_args)
                except Exception,e:
                    import traceback
                    traceback.print_exc()
                    transaction.rollback()
                    error_msg.append("Couldn't update admin opts after deleting the flowspace: %s"%str(e))
            except Exception,e:
                import traceback
                traceback.print_exc()
                transaction.rollback()
                error_msg.append("Flowvisor not set: %s"%str(e))
            
    adminfs = AdminFlowSpace.objects.filter(user=request.user)
    reqfs = RequestedAdminFlowSpace.objects.filter(user=request.user)
    return simple.direct_to_template(request, 
            template = "openflow/optin_manager/admin_manager/admin_unreg_fs.html",
            extra_context = {
                    'reqfs': reqfs,
                    'adminfs': adminfs,
                    'user':request.user,
                    'error_msg':error_msg,
               },
        )
The view function for unregistering  admin flowspaces or pending flowspace requests
dataset/ETHPy150Open fp7-ofelia/ocf/optin_manager/src/python/openflow/optin_manager/admin_manager/views.py/admin_unreg_fs