﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
2835	Processing of urlconf extra args, and removing args	oyvind@…	nobody	"Allows for arguments to be pre-processed to allow urls to be more sensible, ie. comments below blog post.

Also allows arguments to be removed so arguments needed for preprocessing can be removed befor being passed to views.

Not sure if this is a good idea, but i just wanted to see if this is something django needs.

Example code:

form page.models import Page

class comments_urlprocessor:

    def __init__(self, model, args=[]):
        self.model, self.args = model, args

    def __call__(self, *args, **kwargs):

        for key in kwargs.keys():
            if key not in self.args:
                del kwargs['key']

        try:
            commented_object = self.model.objects.get(**kwargs)
        except:
            commented_object = False

        return {'commented_object': commented_object}

info_dict = {
    'queryset': Page.objects.all(),
}

commments_dict = {

    'process_kwargs': ['comments_urlprocessor'],
    'remove_kwargs': ['pk','comments_urlprocessor'],

    'comments_urlprocessor': comments_urlprocessor(Page, ['pk']),
    'commented_object_template': 'page.html'
}

urlpatterns = patterns('',
    (r'^(?P<object_id>\d+)/$', 'django.views.generic.list_detail.object_detail', dict(info_dict, object_id=1, template_name='page.html')),
    (r'^(?P<pk>\d+)/comments/', include('advancedcomments.urls'), commments_dict ),
)
"	enhancement	closed	Core (Other)		normal	wontfix			Design decision needed	0	0	0	0	0	0
