Re: Regex pattern for URL matching
I think this is related to WSGI. On Oct 6, 7:17 pm, Merrick <[EMAIL PROTECTED]> wrote: > That is the approach I took and how I resolved the original problem > with the 404. It led me to find that "AllowEncodedSlashes On" in > Apache is needed for encoded slashes to be allowed in the pathname > information following the filename. > > The problem now is that > > http%3A%2F%2F prints http:/ in my template, > > http%3A%2F also prints out as http:/ > > The second encoded forward slash is being omitted. > > http%3A%2F$2Fwww.wired.com%2Fprints http:/www.wired.com/ > > http%3A%2F$2Fwww.wired.com%2F%2Falso prints http:/www.wired.com/ > > Thanks for looking at this. > > On Oct 6, 5:56 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> > wrote: > > > On Mon, 2008-10-06 at 16:10 -0700, Merrick wrote: > > > keith, thanks for trying. > > > > %2f is the encoded value of /, but urls contain other characters as > > > well not just alphanumeric. > > > I think you're debugging the wrong piece of the problem here. Your > > original regular expression must have been pretty close to the right > > answer, although since it wasn't a valid reg-exp (mis-matched > > parentheses, it's hard to tell). Using "." to match "any character" was > > the right approach. > > > I would start debugging this by trying a simpler example. You said the > > pattern matched "www.wired.com" and then leapt straight to "http%3A%2F% > > 2Fwww.wired.com%2F". So what about something in between, say "%3A" or > > just "www.wored.com%2F". > > > Also, where do things fail? Does the regular expression not match > > anything or does the view not finish for some reason (i.e. do you know > > for sure that the view isn't being called)? Because, again, your > > original regular expression, once you fix the syntax error, looks like > > it should work correctly. > > > Go back to the start, fix the error with the missing parenthese, start > > from something you know works and then add one character at a time until > > it fails. Put debugging prints in your view so that you know if the view > > gets called or not. > > > Regards, > > Malcolm > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Regex pattern for URL matching
That is the approach I took and how I resolved the original problem with the 404. It led me to find that "AllowEncodedSlashes On" in Apache is needed for encoded slashes to be allowed in the pathname information following the filename. The problem now is that http%3A%2F%2F prints http:/ in my template, http%3A%2F also prints out as http:/ The second encoded forward slash is being omitted. http%3A%2F$2Fwww.wired.com%2F prints http:/www.wired.com/ http%3A%2F$2Fwww.wired.com%2F%2F also prints http:/www.wired.com/ Thanks for looking at this. On Oct 6, 5:56 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Mon, 2008-10-06 at 16:10 -0700, Merrick wrote: > > keith, thanks for trying. > > > %2f is the encoded value of /, but urls contain other characters as > > well not just alphanumeric. > > I think you're debugging the wrong piece of the problem here. Your > original regular expression must have been pretty close to the right > answer, although since it wasn't a valid reg-exp (mis-matched > parentheses, it's hard to tell). Using "." to match "any character" was > the right approach. > > I would start debugging this by trying a simpler example. You said the > pattern matched "www.wired.com" and then leapt straight to "http%3A%2F% > 2Fwww.wired.com%2F". So what about something in between, say "%3A" or > just "www.wored.com%2F". > > Also, where do things fail? Does the regular expression not match > anything or does the view not finish for some reason (i.e. do you know > for sure that the view isn't being called)? Because, again, your > original regular expression, once you fix the syntax error, looks like > it should work correctly. > > Go back to the start, fix the error with the missing parenthese, start > from something you know works and then add one character at a time until > it fails. Put debugging prints in your view so that you know if the view > gets called or not. > > Regards, > Malcolm --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Regex pattern for URL matching
On Mon, 2008-10-06 at 16:10 -0700, Merrick wrote: > keith, thanks for trying. > > %2f is the encoded value of /, but urls contain other characters as > well not just alphanumeric. I think you're debugging the wrong piece of the problem here. Your original regular expression must have been pretty close to the right answer, although since it wasn't a valid reg-exp (mis-matched parentheses, it's hard to tell). Using "." to match "any character" was the right approach. I would start debugging this by trying a simpler example. You said the pattern matched "www.wired.com" and then leapt straight to "http%3A%2F% 2Fwww.wired.com%2F". So what about something in between, say "%3A" or just "www.wored.com%2F". Also, where do things fail? Does the regular expression not match anything or does the view not finish for some reason (i.e. do you know for sure that the view isn't being called)? Because, again, your original regular expression, once you fix the syntax error, looks like it should work correctly. Go back to the start, fix the error with the missing parenthese, start from something you know works and then add one character at a time until it fails. Put debugging prints in your view so that you know if the view gets called or not. Regards, Malcolm --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Regex pattern for URL matching
While I have not found the complete solution, I am closer. I added this to my apache settings for the virtual host: AllowEncodedSlashes On I am no longer getting a 404. But even though the url has two instances of %2f to represent two slashes: http://mydomain.com/find/http%3A%2F%2Fwww.wired.com%2F I am able to capture the URL, but with only one slash. I pass it to my ModelForm and it prints in my template as: http:/www.wired.com/ Note the lack of double forward slashes after the colon. On Oct 6, 4:10 pm, Merrick <[EMAIL PROTECTED]> wrote: > keith, thanks for trying. > > %2f is the encoded value of /, but urls contain other characters as > well not just alphanumeric. > > I suspect this issue may have to do with apache or WSGI but not sure > what. > > On Oct 6, 4:06 pm, "Keith Eberle" <[EMAIL PROTECTED]> wrote: > > > quick solution, i think you could add the % to the regex (i'm hardly a > > regex master): > > > r'^find/(?P[%-\w]+)$ > > > keith > > > On Mon, Oct 6, 2008 at 7:05 PM, Merrick <[EMAIL PROTECTED]> wrote: > > > > I have narrowed down the problem to %2F in my url, anyone? > > > > On Oct 6, 2:55 pm, Merrick <[EMAIL PROTECTED]> wrote: > > > > \w will only match alphanumeric characters, I need to match anything > > > > and will let my modelform verify that it is indeed a URL. > > > > > On Oct 6, 2:43 pm, Merrick <[EMAIL PROTECTED]> wrote: > > > > > > Thank you, I meant urls.py. APPEND_SLASH = False so I omitted the > > > > > trailing slash from the regex line: > > > > > > r'^find/(?P[-\w]+)$ > > > > > > and if I pull up the address: > > > > > >http://mydomain.com/find/http%3A%2F%2Fwww.wired.com%2F > > > > > > I still get > > > > > > Not Found > > > > > > The requested URL /find/http://www.wired.com/wasnotfoundon this > > > > > server. > > > > > > I did figure out how to decode the URL in python using unquote_plus(), > > > > > but I cannot figure out this problem. > > > > > > On Oct 6, 1:27 pm, "Keith Eberle" <[EMAIL PROTECTED]> wrote: > > > > > > > it looks like you have mismatched parens, and no trailing slash, > > > which will > > > > > > matter if APPEND_SLASH = True. the regex should look like: > > > > > > > r'^find/(?P[-\w]+)/$' > > > > > > > should be urls.py too, not views.py. > > > > > > > keith > > > > > > > On Mon, Oct 6, 2008 at 1:17 PM, Merrick <[EMAIL PROTECTED]> wrote: > > > > > > > > I am trying to figure out how to match / capture a URL. > > > > > > > > views.py > > > > > > > === > > > > > > > urlpatterns = patterns('', > > > > > > > url(r'^find/(?P(.*)$', > > > > > > > view = 'myapp.views.find', > > > > > > > name = 'find' > > > > > > > ), > > > > > > > > when I enter in this address: > > > > > > > > mydomain.com/find/www.wired.com > > > > > > > > my view / template are executed, but if I do this: > > > > > > > > mydomain.com/find/http%3A%2F%2Fwww.wired.com%2F > > > > > > > > I get: > > > > > > > > Not Found > > > > > > > > The requested URL /find/http://www.wired.com/wasnotfoundonthis > > > > > > > server. > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Regex pattern for URL matching
keith, thanks for trying. %2f is the encoded value of /, but urls contain other characters as well not just alphanumeric. I suspect this issue may have to do with apache or WSGI but not sure what. On Oct 6, 4:06 pm, "Keith Eberle" <[EMAIL PROTECTED]> wrote: > quick solution, i think you could add the % to the regex (i'm hardly a > regex master): > > r'^find/(?P[%-\w]+)$ > > keith > > On Mon, Oct 6, 2008 at 7:05 PM, Merrick <[EMAIL PROTECTED]> wrote: > > > I have narrowed down the problem to %2F in my url, anyone? > > > On Oct 6, 2:55 pm, Merrick <[EMAIL PROTECTED]> wrote: > > > \w will only match alphanumeric characters, I need to match anything > > > and will let my modelform verify that it is indeed a URL. > > > > On Oct 6, 2:43 pm, Merrick <[EMAIL PROTECTED]> wrote: > > > > > Thank you, I meant urls.py. APPEND_SLASH = False so I omitted the > > > > trailing slash from the regex line: > > > > > r'^find/(?P[-\w]+)$ > > > > > and if I pull up the address: > > > > >http://mydomain.com/find/http%3A%2F%2Fwww.wired.com%2F > > > > > I still get > > > > > Not Found > > > > > The requested URL /find/http://www.wired.com/wasnotfound on this > > > > server. > > > > > I did figure out how to decode the URL in python using unquote_plus(), > > > > but I cannot figure out this problem. > > > > > On Oct 6, 1:27 pm, "Keith Eberle" <[EMAIL PROTECTED]> wrote: > > > > > > it looks like you have mismatched parens, and no trailing slash, > > which will > > > > > matter if APPEND_SLASH = True. the regex should look like: > > > > > > r'^find/(?P[-\w]+)/$' > > > > > > should be urls.py too, not views.py. > > > > > > keith > > > > > > On Mon, Oct 6, 2008 at 1:17 PM, Merrick <[EMAIL PROTECTED]> wrote: > > > > > > > I am trying to figure out how to match / capture a URL. > > > > > > > views.py > > > > > > === > > > > > > urlpatterns = patterns('', > > > > > > url(r'^find/(?P(.*)$', > > > > > > view = 'myapp.views.find', > > > > > > name = 'find' > > > > > > ), > > > > > > > when I enter in this address: > > > > > > > mydomain.com/find/www.wired.com > > > > > > > my view / template are executed, but if I do this: > > > > > > > mydomain.com/find/http%3A%2F%2Fwww.wired.com%2F > > > > > > > I get: > > > > > > > Not Found > > > > > > > The requested URL /find/http://www.wired.com/wasnotfoundon this > > > > > > server. > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Regex pattern for URL matching
quick solution, i think you could add the % to the regex (i'm hardly a regex master): r'^find/(?P[%-\w]+)$ keith On Mon, Oct 6, 2008 at 7:05 PM, Merrick <[EMAIL PROTECTED]> wrote: > > I have narrowed down the problem to %2F in my url, anyone? > > > > On Oct 6, 2:55 pm, Merrick <[EMAIL PROTECTED]> wrote: > > \w will only match alphanumeric characters, I need to match anything > > and will let my modelform verify that it is indeed a URL. > > > > On Oct 6, 2:43 pm, Merrick <[EMAIL PROTECTED]> wrote: > > > > > Thank you, I meant urls.py. APPEND_SLASH = False so I omitted the > > > trailing slash from the regex line: > > > > > r'^find/(?P[-\w]+)$ > > > > > and if I pull up the address: > > > > >http://mydomain.com/find/http%3A%2F%2Fwww.wired.com%2F > > > > > I still get > > > > > Not Found > > > > > The requested URL /find/http://www.wired.com/wasnot found on this > > > server. > > > > > I did figure out how to decode the URL in python using unquote_plus(), > > > but I cannot figure out this problem. > > > > > On Oct 6, 1:27 pm, "Keith Eberle" <[EMAIL PROTECTED]> wrote: > > > > > > it looks like you have mismatched parens, and no trailing slash, > which will > > > > matter if APPEND_SLASH = True. the regex should look like: > > > > > > r'^find/(?P[-\w]+)/$' > > > > > > should be urls.py too, not views.py. > > > > > > keith > > > > > > On Mon, Oct 6, 2008 at 1:17 PM, Merrick <[EMAIL PROTECTED]> wrote: > > > > > > > I am trying to figure out how to match / capture a URL. > > > > > > > views.py > > > > > === > > > > > urlpatterns = patterns('', > > > > >url(r'^find/(?P(.*)$', > > > > >view = 'myapp.views.find', > > > > >name = 'find' > > > > >), > > > > > > > when I enter in this address: > > > > > > > mydomain.com/find/www.wired.com > > > > > > > my view / template are executed, but if I do this: > > > > > > > mydomain.com/find/http%3A%2F%2Fwww.wired.com%2F > > > > > > > I get: > > > > > > > Not Found > > > > > > > The requested URL /find/http://www.wired.com/wasnotfound on this > > > > > server. > > > > > > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Regex pattern for URL matching
I have narrowed down the problem to %2F in my url, anyone? On Oct 6, 2:55 pm, Merrick <[EMAIL PROTECTED]> wrote: > \w will only match alphanumeric characters, I need to match anything > and will let my modelform verify that it is indeed a URL. > > On Oct 6, 2:43 pm, Merrick <[EMAIL PROTECTED]> wrote: > > > Thank you, I meant urls.py. APPEND_SLASH = False so I omitted the > > trailing slash from the regex line: > > > r'^find/(?P[-\w]+)$ > > > and if I pull up the address: > > >http://mydomain.com/find/http%3A%2F%2Fwww.wired.com%2F > > > I still get > > > Not Found > > > The requested URL /find/http://www.wired.com/wasnot found on this > > server. > > > I did figure out how to decode the URL in python using unquote_plus(), > > but I cannot figure out this problem. > > > On Oct 6, 1:27 pm, "Keith Eberle" <[EMAIL PROTECTED]> wrote: > > > > it looks like you have mismatched parens, and no trailing slash, which > > > will > > > matter if APPEND_SLASH = True. the regex should look like: > > > > r'^find/(?P[-\w]+)/$' > > > > should be urls.py too, not views.py. > > > > keith > > > > On Mon, Oct 6, 2008 at 1:17 PM, Merrick <[EMAIL PROTECTED]> wrote: > > > > > I am trying to figure out how to match / capture a URL. > > > > > views.py > > > > === > > > > urlpatterns = patterns('', > > > > url(r'^find/(?P(.*)$', > > > > view = 'myapp.views.find', > > > > name = 'find' > > > > ), > > > > > when I enter in this address: > > > > > mydomain.com/find/www.wired.com > > > > > my view / template are executed, but if I do this: > > > > > mydomain.com/find/http%3A%2F%2Fwww.wired.com%2F > > > > > I get: > > > > > Not Found > > > > > The requested URL /find/http://www.wired.com/wasnotfound on this > > > > server. > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Regex pattern for URL matching
Thank you, I meant urls.py. APPEND_SLASH = False so I omitted the trailing slash from the regex line: r'^find/(?P[-\w]+)$ and if I pull up the address: http://mydomain.com/find/http%3A%2F%2Fwww.wired.com%2F I still get Not Found The requested URL /find/http://www.wired.com/ was not found on this server. I did figure out how to decode the URL in python using unquote_plus(), but I cannot figure out this problem. On Oct 6, 1:27 pm, "Keith Eberle" <[EMAIL PROTECTED]> wrote: > it looks like you have mismatched parens, and no trailing slash, which will > matter if APPEND_SLASH = True. the regex should look like: > > r'^find/(?P[-\w]+)/$' > > should be urls.py too, not views.py. > > keith > > On Mon, Oct 6, 2008 at 1:17 PM, Merrick <[EMAIL PROTECTED]> wrote: > > > I am trying to figure out how to match / capture a URL. > > > views.py > > === > > urlpatterns = patterns('', > > url(r'^find/(?P(.*)$', > > view = 'myapp.views.find', > > name = 'find' > > ), > > > when I enter in this address: > > > mydomain.com/find/www.wired.com > > > my view / template are executed, but if I do this: > > > mydomain.com/find/http%3A%2F%2Fwww.wired.com%2F > > > I get: > > > Not Found > > > The requested URL /find/http://www.wired.com/was not found on this > > server. > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Regex pattern for URL matching
\w will only match alphanumeric characters, I need to match anything and will let my modelform verify that it is indeed a URL. On Oct 6, 2:43 pm, Merrick <[EMAIL PROTECTED]> wrote: > Thank you, I meant urls.py. APPEND_SLASH = False so I omitted the > trailing slash from the regex line: > > r'^find/(?P[-\w]+)$ > > and if I pull up the address: > > http://mydomain.com/find/http%3A%2F%2Fwww.wired.com%2F > > I still get > > Not Found > > The requested URL /find/http://www.wired.com/was not found on this > server. > > I did figure out how to decode the URL in python using unquote_plus(), > but I cannot figure out this problem. > > On Oct 6, 1:27 pm, "Keith Eberle" <[EMAIL PROTECTED]> wrote: > > > it looks like you have mismatched parens, and no trailing slash, which will > > matter if APPEND_SLASH = True. the regex should look like: > > > r'^find/(?P[-\w]+)/$' > > > should be urls.py too, not views.py. > > > keith > > > On Mon, Oct 6, 2008 at 1:17 PM, Merrick <[EMAIL PROTECTED]> wrote: > > > > I am trying to figure out how to match / capture a URL. > > > > views.py > > > === > > > urlpatterns = patterns('', > > > url(r'^find/(?P(.*)$', > > > view = 'myapp.views.find', > > > name = 'find' > > > ), > > > > when I enter in this address: > > > > mydomain.com/find/www.wired.com > > > > my view / template are executed, but if I do this: > > > > mydomain.com/find/http%3A%2F%2Fwww.wired.com%2F > > > > I get: > > > > Not Found > > > > The requested URL /find/http://www.wired.com/wasnot found on this > > > server. > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Regex pattern for URL matching
it looks like you have mismatched parens, and no trailing slash, which will matter if APPEND_SLASH = True. the regex should look like: r'^find/(?P[-\w]+)/$' should be urls.py too, not views.py. keith On Mon, Oct 6, 2008 at 1:17 PM, Merrick <[EMAIL PROTECTED]> wrote: > > I am trying to figure out how to match / capture a URL. > > views.py > === > urlpatterns = patterns('', >url(r'^find/(?P(.*)$', >view = 'myapp.views.find', >name = 'find' >), > > when I enter in this address: > > mydomain.com/find/www.wired.com > > my view / template are executed, but if I do this: > > mydomain.com/find/http%3A%2F%2Fwww.wired.com%2F > > I get: > > Not Found > > The requested URL /find/http://www.wired.com/ was not found on this > server. > > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Regex pattern for URL matching
I am trying to figure out how to match / capture a URL. views.py === urlpatterns = patterns('', url(r'^find/(?P(.*)$', view = 'myapp.views.find', name = 'find' ), when I enter in this address: mydomain.com/find/www.wired.com my view / template are executed, but if I do this: mydomain.com/find/http%3A%2F%2Fwww.wired.com%2F I get: Not Found The requested URL /find/http://www.wired.com/ was not found on this server. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---