Forums

Inconsistencies.

I have this url pattern defined in my urls.py

^define/(?P<post_id>\w+)/(?P<simpler_id>\w+)/newxhex/(?P<new_simpler>[\w|\W]+)/oldxhex/(?P<old_simpler>[\w|\W]*)/$

This is the url:

http://simpler.pythonanywhere.com/define/1/1/newxhex/%3Cp%3EDefibrillators%20don't%20revive%20dead%20patients,%20they%20merely%20help%20correct%20cardiac%20dysrythmia.%20Cardiac%20dysrythmia%20is%20the%20condition%20of%20a%20human%20heart%20where%20electrical%20activity%20of%20the%20heart%20is%20irregular.%20This%20might%20result%20in%20heartbeats%20being%20faster,%20slower,%20irregular%20or%20regular.%3C/p%3E%3Cp%3EMovies%20show%20just %3Cspan%20class=%22highlight%22%20id=%221%22%20data=%221%22%3Eone%20of%20these%20cases%20where%20the%20heart%20beat%20of%20the%20patient%20is%20down%20to%20zero,%20for%20purposes%20of%20dramatization  %3Cinput%20type=%22checkbox%22%20class=%22checkedhigh%22%20value=%22one_of%20these%20cases%20where%20the%20heart%20beat%20of%20the%20patient%20is%20down%20to%20zero,%20for%20purposes%20of%20dramatization %22%20name=%22highlight%22%20style=%22display:%20inline-block;%22%3E%3C/span%3E .%3C/p%3E%3Cp%3EThe%20electrodes%20of%20the%20difibrillator%20is%20positioned%20so%20as%20to%20pass%20a%20therapeutic%20amount%20of%20electric%20shock%20through%20the%20human%20heart,%20thus %3Cspan%20class=%22highlight%22%20id=%221%22%20data=%221%22%3Edepolarizing%20the%20critical%20mass   %3Cinput%20type=%22checkbox%22%20class=%22checkedhigh%22%20value=%22depolarizing_the%20critical%20mass  %22%20name=%22highlight%22%20style=%22display:%20inline-block;%22%3E%3C/span%3E and%20resuming%20normal%20electric%20activity%20in%20the%20heart.%20The%20positioning%20is %3Cspan%20class=%22curr_highlight%22%20id=%221%22%20data=%221%22%3Eimportant %3Cinput%20type=%22checkbox%22%20class=%22curr_checkedhigh%22%20value=%22important%22%20name=%22highlight%22%20style=%22display:%20none;%22%3E%3C/span%3E  and%20is%20shown%20below:%3C/p%3E%3Cp%3E%3Cimg%20src=%22http://upload.wikimedia.org/wikipedia/commons/thumb/6/6e/Defibrillation_Electrode_Position.jpg/464px-Defibrillation_Electrode_Position.jpg%22%3E%3C/p%3E/oldxhex//

And it throws a 404 error at me.

What is weird is that the url pattern works perfectly fine on my localhost, i.e replacing 'simpler.pythonanywhere.com' from the url with '127.0.0.1' yields success. What could possibly be wrong?

You could try out the expression in a console maybe, both locally and on the server, and see if the regex is working the way you think it should?

import re
s = '''define/1/1/newxhex/%3Cp%3EDefibrill.etc.etc//'''
r = r"^define/(?P<post_id>\w+)/(?P<simpler_id>\w+)/newxhex/(?P<new_simpler>[\w|\W]+)/oldxhex/(?P<old_simpler>[\w|\W]*)/$"
m = re.match(r, s)
print m.groupdict()

Yea. I got that. I think I have to change the apache configuration to get this fixed. Where do I find the apache configuration file?

Apache is not involved... Why, what do you think is happening?

I think it has to do with the WSGIScriptAlias setting. A slash missing somewhere most probably.

There?

Hm. I suppose it's possible that something in our stack is treating URLs slightly differently from the way your local web server does it -- perhaps stripping out a slash from the beginning or the end?

In any case, unfortunately it's not something that we'll be able to change. Can you debug your regex to find out exactly what's happening, and/or adjust it so it's resilient to differences in trailing or leading slashes?

Ok then. I'll check it out. Thanks :)