####### file: newpatern/defaults.py #######

from django.conf.urls.defaults import url

class AddNewUrl(object):
    def __init__(self,prefix,view,*t):
        self.prefix = prefix
        self.view = view
        self.t = t
    def __call__(self,*t,**k):
        if 'before' in self.prefix :
            ret = self.prefix['before'](*t,**k)
            if ret:
                return ret
        ret =  self.view(*t,**k)
        if 'after' in self.prefix:
            self.prefix['after'](*t,**k)
        return ret

def newpatterns(prefix, *args):
    pattern_list = []
    for t in args:
        pattern_list.append(newurl(prefix, *t))
    return pattern_list

def newurl(prefix,regex,view,*t):
    return url(regex,AddNewUrl(prefix,view,*t),*t)


def classpatterns(cp):
    o_cp = cp()
    cp_prefix = {}
    if hasattr(o_cp,'before_cp'):
        before_cp = getattr(o_cp,'before_cp')
        if callable(before_cp):
            cp_prefix['before'] = before_cp
    func_list = ()
    for item in dir(o_cp):
        if item.startswith('cp__'):
            item_func = getattr(o_cp,item)
            if callable(item_func):
                func_list = func_list + ((r'^'+item[4:]+'/$',item_func),)
    #raise str(func_list)
    return newpatterns(cp_prefix,*func_list)


##### in your project ####################

##### file: ajax/vurls.py ################
from newpatern.defaults import newpatterns, classpatterns
from django.http import HttpResponse
class Views(object):
    def before__cp(self,request):
        pass #any code running before /test1 or /test2

    def cp__test1(self,request):
    	return HttpResponse('This is URL of TEST1!');
    
    def cp__test2(self,request):
    	return HttpResponse('This is URL of TEST2!');
    
    

urlpatterns = classpatterns(Views)


##### file: urls.py #####################
# just Add in you patterns list 
(r'^ajax/',include('ajax.vurls'))

#### Respons #####
# GET ajax/test1/
# Respons:This is URL of TEST1!

# GET ajax/test2/
# Respons:This is URL of TEST2!