Simple one, I'm sure. In short, can the Django URL dispatcher tell
between

http://site.com/first%2esecond.json

and

http://site.com/first.second.json

?

The reason is that I have a RESTful API, where the object name can be
used to address it, and I'd like the name to be able to contain
periods. If they are escaped (as in the first line above), it should
be clear that the .json is referring to the serialisation, and is not
part of the name (which is "first.second")

But Django seems to get the URL already unescaped, meaning it
thinks .second (or .second.json) is the serialisation.

Simplified, the regex is:

portions = {
    'id': '(?P<id>[.a-z]+)',
    'emitter': '\.(?P<emitter_format>json|xml|yaml|pickle)',
}
...
urlpatterns = patterns('',
 url('^%(id)s%(emitter)s$' % portions, api),
)


So I would expect that something like:

    'id': '(?P<id>[%0-9a-z]+)',

Would be able to pick up escaped punctuation (which I am perfectly
happy to unescape myself, later). But it does not, since %2e has
already become . before the regex is applied.

Is there an accepted idiom for Django and escaped characters in URLs?

(Life used to be so simple when most of the interesting bits of a URL
were in the querystring ;-) )

Many thanks for any ideas.

James
PS. I use the wonderful Piston, by the way. Not relevant, just a shout
out!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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