On 10/21/2010 2:24 PM, ringemup wrote:
> You can't do something like this?
> 
> #urls.py
> #note: untested regex, but a regex should be able to do this
> url('^((\w+)/(\d+)/)+$', 'myview', ...)
> 
> #views.py
> # note: this is pseudocode
> def myview(request, *args, **kwargs):
>   # iterate through args two at a time
>   for func, arg in args:

This, sadly, does not iterate over the arguments two at a time.

>>> for a, b in [1, 2, 3, 4]:
...     print a, b
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'int' object is not iterable
>>>

But you said it was pseudocode, so you are forgiven.

You could try something like:

    args = iter(args)    # may need args.__iter__() in earlier Pythons?
    for func in args:
        arg = next(args) # may need args.next() in earlier Pythons?
           ...

>     if func in list_of_allowed_funcs:
>       func(arg)
>   return HttpResponse('whatever')
> 
regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to