def resolve_object(request, model, query, permission='base.view_resourcebase', permission_required=True, permission_msg=None):
 obj = get_object_or_404(model, **query)
 obj_to_check = obj.get_self_resource()
 if settings.RESOURCE_PUBLISHING:
  if ((not obj_to_check.is_published) and (not request.user.has_perm('publish_resourcebase', obj_to_check))):
   raise Http404
 allowed = True
 if (permission.split('.')[(-1)] in ['change_layer_data', 'change_layer_style']):
  if (obj.__class__.__name__ == 'Layer'):
   obj_to_check = obj
 if permission:
  if (permission_required or (request.method != 'GET')):
   allowed = request.user.has_perm(permission, obj_to_check)
 if (not allowed):
  mesg = (permission_msg or _('Permission Denied'))
  raise PermissionDenied(mesg)
 return obj

def resolve_object ( request , model , query , permission = 'base.view_resourcebase' , permission_required = True , permission_msg = None ) : obj = get_object_or_404 ( model , ** query ) obj_to_check = obj . get_self_resource ( ) if settings . RESOURCE_PUBLISHING : if ( ( not obj_to_check . is_published ) and ( not request . user . has_perm ( 'publish_resourcebase' , obj_to_check ) ) ) : raise Http404 allowed = True if ( permission . split ( '.' ) [ ( - 1 ) ] in [ 'change_layer_data' , 'change_layer_style' ] ) : if ( obj . __class__ . __name__ == 'Layer' ) : obj_to_check = obj if permission : if ( permission_required or ( request . method != 'GET' ) ) : allowed = request . user . has_perm ( permission , obj_to_check ) if ( not allowed ) : mesg = ( permission_msg or _ ( 'Permission Denied' ) ) raise PermissionDenied ( mesg ) return obj
resolve an object using the provided query and check the optional permission .