## exampleapp/views.py
import re
from django.http import Http404, HttpResponse
from django.utils.datastructures import SortedDict

class RouterView(object):
    def __init__(self):
        self.mapping = SortedDict()

    def register(self, *args):
        for regex, view_func in args:
            self.mapping[re.compile(regex)] = view_func

    def __call__(self, request, *args, **kwargs):
        for regex, view_func in self.mapping.items():
            if regex.match(request.path[1:]):
                return view_func(request, *args, **kwargs)
        # does not match
        raise Http404

def some_view(request):
    return HttpResponse('test')

## urls.py
from django.conf.urls.defaults import *
from exampleapp.views import RouterView, some_view

router = RouterView()
router.register(
    (r'^foo/', some_view),
)

urlpatterns = patterns('',
    (r'', router),
    (r'foo/bar/', router),
)