On Mon, Feb 15, 2010 at 6:06 AM, Jonathan Sutcliffe <
jonosutcli...@googlemail.com> wrote:

>
> I want to pass a URL of the following form, containing an email
> address that I will later look up contact information from.
>
> e.g.  http://localhost:8000/contact/ronald.ninnis%40cdu.edu.au/
>
> I don't care about whether this is a valid email string I simple want
> to pass the parameter across to the view and do the look up here.
>
> I notice the @ is already %40 which has been escaped by the Javascript
> in the calling application.
>
> In my urls.py I have the following regex.
>
> urls.py
>
>  (r'^contact/(?P<email>\[a-z0-9._%+...@[a-z0-9.-]+\.[a-z]{2,4})/$',
> 'entitlements.sfdc.views.contactdetail'),
>
> But no match is found. Could someone point out the error of my ways?
>

If you do not care if it is a valid email string why are you attempting any
kind of 'looks like an email' matching in the url pattern?

As for what, specifically, is wrong with that pattern -- the \ after <email>
looks wrong, and the fact that you've specified all uppercase letters to
match yet the sample URL you show has lowercase letters looks like a
problem, for starters. But really I would hesitate to try to 'fix' that
pattern, particularly if you really don't care if it is a valid email
address at this point in the code. Just switch it to something that accepts
anything between the two slashes in the url, and if you do care about
checking validity later in processing, use some other pre-existing email
validation code to check the value once you've got it in the view.

Karen

-- 
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