Discussion:
[albatross-users] bug in RandomPageModuleMixin.load_page
Nickolay Savchenko
2010-05-14 18:50:05 UTC
Permalink
Hi all!

load_page method of RandomPageModuleMixin seems to have a bug. If URL
has dots this method doesn't catch ApplicationError correctly, and
server returns 500 error instead of 404.

Traceback is following:

2010-04-07 17:37:32.215924: //phpMyAdmin/config/config.inc.php?c=uptime
Traceback (most recent call last):
File "/var/www/ivi/website/modules/app.py", line 167, in run
self.load_page(ctx)
File "/usr/lib/python2.5/site-packages/albatross/randompage.py",
line 29, in load_page
self.load_page_module(ctx, page)
File "/usr/lib/python2.5/site-packages/albatross/app.py", line 437,
in load_page_module
raise ApplicationError('%s (in %s)' % (e, mod_dir))
ApplicationError: No module named php (in
/var/www/ivi/website/pages/config/config/inc)

This can be easily fixed with attached patch.
--
Best regards,
Nickolay S. Savchenko
-------------- next part --------------
A non-text attachment was scrubbed...
Name: load_page.patch
Type: text/x-patch
Size: 466 bytes
Desc: not available
URL: <http://www.object-craft.com.au/pipermail/albatross-users/attachments/20100514/d0546bfb/attachment.bin>
Andrew McNamara
2010-05-27 07:46:21 UTC
Permalink
Post by Nickolay Savchenko
load_page method of RandomPageModuleMixin seems to have a bug. If URL
has dots this method doesn't catch ApplicationError correctly, and
server returns 500 error instead of 404.
2010-04-07 17:37:32.215924: //phpMyAdmin/config/config.inc.php?c=uptime
File "/var/www/ivi/website/modules/app.py", line 167, in run
self.load_page(ctx)
File "/usr/lib/python2.5/site-packages/albatross/randompage.py",
line 29, in load_page
self.load_page_module(ctx, page)
File "/usr/lib/python2.5/site-packages/albatross/app.py", line 437,
in load_page_module
raise ApplicationError('%s (in %s)' % (e, mod_dir))
ApplicationError: No module named php (in
/var/www/ivi/website/pages/config/config/inc)
This can be easily fixed with attached patch.
Thanks for the bug report! I've implemented a slightly different fix
that creates an ApplicationError subclass called PageNotFound and thus
avoids the need for searching in strings. Can you try this out and let
me know if it fixes the problem equally well (sorry, I haven't had a
chance to replicate it yet)?
--
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: albatross-randompage-patch
Type: text/x-patch
Size: 1768 bytes
Desc: not available
URL: <http://www.object-craft.com.au/pipermail/albatross-users/attachments/20100527/8eb89b7a/attachment.bin>
Nickolay Savchenko
2010-05-27 11:18:26 UTC
Permalink
Tested patch against 1.36, it works. But one test is failing now, below is fix:

Index: test/misc/pagemodule.py
===================================================================
--- test/misc/pagemodule.py (revision 7516)
+++ test/misc/pagemodule.py (working copy)
@@ -67,7 +67,7 @@

def missing_module(self):
self._mod_regexp('nonexistent_module',
- 'ApplicationError: No module named')
+ 'PageNotFound: No module named')

def simple_page_module(self):
self._mod_result('simple_module', '')
Post by Andrew McNamara
Post by Nickolay Savchenko
load_page method of RandomPageModuleMixin seems to have a bug. If URL
has dots this method doesn't catch ApplicationError correctly, and
server returns 500 error instead of 404.
2010-04-07 17:37:32.215924: //phpMyAdmin/config/config.inc.php?c=uptime
? File "/var/www/ivi/website/modules/app.py", line 167, in run
? ? self.load_page(ctx)
? File "/usr/lib/python2.5/site-packages/albatross/randompage.py",
line 29, in load_page
? ? self.load_page_module(ctx, page)
? File "/usr/lib/python2.5/site-packages/albatross/app.py", line 437,
in load_page_module
? ? raise ApplicationError('%s (in %s)' % (e, mod_dir))
ApplicationError: No module named php (in
/var/www/ivi/website/pages/config/config/inc)
This can be easily fixed with attached patch.
Thanks for the bug report! I've implemented a slightly different fix
that creates an ApplicationError subclass called PageNotFound and thus
avoids the need for searching in strings. Can you try this out and let
me know if it fixes the problem equally well (sorry, I haven't had a
chance to replicate it yet)?
--
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/
--
Best regards,
Nickolay S. Savchenko
Andrew McNamara
2010-05-27 12:44:50 UTC
Permalink
Ah, thanks!

I'll also need to update the docs, and work out how to add a unittest
for the problem you found.
--
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/
Loading...