|
Nicolas Lehuen made changes - 10/Aug/05 09:53 PM
I definitely mean "page.py". I am definitely not suggesting that you have Python code
in an actual physical file called "page.html". I am suggesting you access it though as "page.html". Accessing "page.html" should return HTML output. Accessing "page.py" will return Python source code, although because it contains HTML it will not look correct as markup will disappear. Not sure why you can't duplicate it. On mod_python 3.1.3 it works for me with whether or not MultiViews is enabled. On mod_python subversion head though, it doesn't work at all and thus the basis of the bug report about it. What happens is that since "page.html" doesn't map to an actual physical file, it gets passed through in req.filename in total. Eg. dumping out req attributes at start of publisher you should see: [Sat Aug 27 19:53:26 2005] [error] req.uri='/~grahamd/mp32/page.html' [Sat Aug 27 19:53:26 2005] [error] req.filename='/Users/grahamd/Sites/mp32/page.html' [Sat Aug 27 19:53:26 2005] [error] req.path_info='' It then fails the "if exists(req.filename)" check and in the "else" case it will check for "isfile(req.filename+'.py')". Ie., checks for "page.html.py" which also wouldn't exist. It therefore falls through to sticking "index.py" explicitly in req.filename and when that doesn't exist raises Python error because of other problem I have highlighted. The only way it would work is if "index.py" existed and in it it had something that would resolve if "page.html" were mapped against it as "func_path". This would be unlikely. Anyway, I will work on a fix. Another bug in this new publisher code is that when SetHandler is used, in 3.1.3
it would only pay attention to files matched which had a ".py" extension. Actually it would match anything returned by imp.get_suffixes(), but then it had some subtle bugs in that as well, as described in This all mean't that if you had "page.py" and "page.html" in a directory together and you access "page.html" it would return not found. In the new publisher it attempts to load the "page.html" file as Python code, which yields a syntax error like: File "/Users/grahamd/Sites/mp32/page.html", line 1 ^ SyntaxError: invalid syntax
Jim, can you give this patch I have attached a go. What I have done is incorporated
the equivalent publisher code I had from Vampire where I already worked out fixes for all the original publisher problems. This code also handles correctly the cases for where the new publisher code has introduced problems as described above and elsewhere. The code is well commented and I believe it is perhaps a bit easier to follow anyway. I haven't checked it against the test suite after having integrated it, just a few cases covering the problematic areas where current problems are, so if you can run the test suite other it, would be appreciated. We can then see where we go with this, whether my alternative is going to be acceptable or whether it is going to be necessary to try and make what was there work instead.
Graham Dumpleton made changes - 27/Aug/05 08:49 PM
Integrated Graham's patch, ran the unit test suite, everything is OK. Graham, I need a confirmation for your particular test case, though.
Nicolas Lehuen made changes - 28/Aug/05 05:47 AM
Graham Dumpleton made changes - 05/Mar/06 02:18 PM
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ie.
# page.html
def index():
return "<html></body><p>XXX</p></body></html>"
works fine for me.
Likewise if I have a file stuff.html:
# stuff.html
def index(req):
return "<html></body><p>
MODPYTHON-72stuff</p></body></html>"calling either "/stuff" or "/stuff.html" returns the correct page.