from django.conf.urls.defaults import patterns as django_patterns from django.conf.urls.defaults import url def patterns(*urls): pages = [] for cls in urls: if isinstance(cls, type): inst = cls() pages.append(url(inst.url, inst.resource, name = inst.name)) else: #oldstyle resources pages.append(cls) return django_patterns(*pages) class Page(object): url = r"^$" def resource(self, request, *args, **kwargs): if request.method == "GET": return self.get(request, *args, **kwargs) if request.method == "POST": return self.post(request, *args, **kwargs) @property def name(self): return "%s-%s" % (self.__class__.__name__, "page")