I'm using the .96 release and it seems like URLConf is passing my
parameters as positional, even though they are named. Can anyone guess
why this fails? When I wrap a view function with a decorator the named
arguments seem to be converted to positional. At first I caught the
KeyError and defaulted to a positional argument, but with the
Decorator in wide spread usage I can no longer predict what position
the argument will be in.
#urls.py
urlpatterns = patterns('',
...
(r'^builder/', include('builder_urls')),
)
#builder_urls.py
urlpatterns = patterns('builder_views',
(r'^(?P<builder_id>\d+)/profile/$', 'builder_profile'),
)
#builder_views.py
from django.contrib.auth import decorators
from decorators import *
@decorators.login_required
@builder_ok
def builder_profile( request, builder_id ):
"""Shows reports, options to change settings"""
return render_to_response(
'builder_profile.html',
dict(
builder=request.builder,
), context_instance=RequestContext(request)
)
#decorators.py
from decorator import decorator #http://www.phyast.pitt.edu/~micheles/
python/documentation.html
@decorator
def builder_ok( view_func, request, *args, **kwargs ):
builder_id = kwargs['builder_id'] ########### <----- This fails
with a KeyError
request.builder = get_object_or_404( Builder, pk=builder_id )
if request.builder not in request.user.builders.all():
# Error condition, user is not an author for this builder
return HttpResponseForbidden()
return view_func( 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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---