@simple_decorator
def check_local_site_access(view_func):
 def _check(request, local_site_name=None, *args, **kwargs):
  if local_site_name:
   if (not request.local_site):
    raise Http404
   local_site = request.local_site
   if (not local_site.is_accessible_by(request.user)):
    if (local_site.public or request.user.is_authenticated()):
     response = render_to_response('permission_denied.html', RequestContext(request))
     response.status_code = 403
     return response
    else:
     return HttpResponseRedirect(('%s?next_page=%s' % (reverse('login'), request.get_full_path())))
  else:
   local_site = None
  return view_func(request, local_site=local_site, *args, **kwargs)
 return _check

@ simple_decorator def check_local_site_access ( view_func ) : def _check ( request , local_site_name = None , * args , ** kwargs ) : if local_site_name : if ( not request . local_site ) : raise Http404 local_site = request . local_site if ( not local_site . is_accessible_by ( request . user ) ) : if ( local_site . public or request . user . is_authenticated ( ) ) : response = render_to_response ( 'permission_denied.html' , RequestContext ( request ) ) response . status_code = 403 return response else : return HttpResponseRedirect ( ( '%s?next_page=%s' % ( reverse ( 'login' ) , request . get_full_path ( ) ) ) ) else : local_site = None return view_func ( request , local_site = local_site , * args , ** kwargs ) return _check
checks if a user has access to a local site .