[albatross-users] Bug in 1.10 w/ mod_python 2.7.8 / Apache 1.3

Gregory Bond gnb at itga.com.au
Thu Jul 24 18:01:42 EST 2003


Using checkboxes in a form works fine as a CGI and under mod_python 3 on 
Apache 2, but causes an exception under mod_python 2.7.8 on Apache 1.3.  


Traceback (most recent call last):
  File "/usr/local/lib/python2.1/site-packages/albatross/app.py", line 246, in run
    self.merge_request(ctx)
  File "/usr/local/lib/python2.1/site-packages/albatross/app.py", line 326, in merge_request
    ctx.merge_request()
  File "/usr/local/lib/python2.1/site-packages/albatross/context.py", line 309, in merge_request
    value = self.request.field_value(name)
  File "/usr/local/lib/python2.1/site-packages/albatross/cgiapp.py", line 33, in field_value
    return [f.value for f in field]
AttributeError: value

In mod_python 3 the elements of field[] are mod_python.util.StringField
objects, under mod_python2 they are strings.

(I never ran albatross 1.01 under mod_python 2 so this may be an old bug.)

The attached patch seems to fix it:


-------------- next part --------------
--- albatross/cgiapp.py.DIST	Thu Jul 24 17:58:00 2003
+++ albatross/cgiapp.py	Thu Jul 24 17:59:26 2003
@@ -30,6 +30,10 @@
     def field_value(self, name):
         field = self.__fields[name]
         if isinstance(field, type([])):
+	    if isinstance(field[0], type('')):
+		# for checkboxes, this is a vec of strings in mod_python 2
+	        return field
+	    # but a vec of utils.FieldStorage objects in mod_python 3
             return [f.value for f in field]
         elif isinstance(field, type('')):
             return field                # Weird - blame mod_apache?


More information about the Albatross-users mailing list