You should and must do such things at middleware (as god intended). example: http://www.djangosnippets.org/snippets/845/ just return custom HttpResponse, not HttpResponseForbiden
Kristaps Kūlis On Sun, Oct 4, 2009 at 8:41 PM, Kurt <kneuf...@burgundywall.com> wrote: > > > I think I must be doing something fundamentally wrong since this seems > like an easy problem... > > I'm building a site, I want all ips not in INTERNAL_IPS to get an > "under construction" page and my internal ips to get the real site. > What I'm trying to do is call the application urlconf via the resolve > function. > > The redirect to the construction page works fine. > > The resolve seems to work since the /admin/ pages work but > django_authopenid do not, I get strange errors like "Reverse for > 'user_sendpw' with arguments '()' and keyword arguments '{}' not > found." > > If I change settings.py:ROOT_URLCONF to be "myapp.urls" then > authopenid works. > > settings.py: > ROOT_URLCONF = 'redirector.urls' > > redirector/urls.py: > urlpatterns = patterns('', > (r'^', 'redirector.views.redirect' ), > ) > > redirector/views.py: > def redirect(request, *args, **kwargs): > remote_addr = request.META['REMOTE_ADDR'] > is_internal = remote_addr in settings.INTERNAL_IPS > > if not is_internal: > return render_to_response( 'construction.html' ) > > uri = request.META.get('REQUEST_URI', '/' ) > > # if we're an internal ip address then find the application > urlconf > app = settings.SETTINGS_MODULE.split( "." )[0] > app_urls = app + ".urls" > > # FANCY BIT IS RIGHT HERE > view, args, kwargs = resolve( urlparse(uri)[2], app_urls ) > > return view(request, *args, **kwargs) > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---