-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

I have upload field with IS_IMAGE validator, which allow only gif,jpg.
If I try to upload bmp, it leads to a weird uncaught exception:

Traceback (most recent call last):
  File "/opt/web2py/gluon/restricted.py", line 176, in restricted
    exec ccode in environment
  File "/opt/web2py/applications/jfind/controllers/users.py", line 1571,
in <module>
  File "/opt/web2py/gluon/globals.py", line 100, in <lambda>
    self._caller = lambda f: f()
  File "/opt/web2py/applications/jfind/controllers/users.py", line 868,
in update_my_profile
    if form.accepts(request.vars, session):
  File "/opt/web2py/gluon/sqlhtml.py", line 738, in accepts
    if not request_vars.get(key,None) and self.table[key].type=='upload' \
  File "/usr/lib/python2.5/cgi.py", line 633, in __len__
    return len(self.keys())
  File "/usr/lib/python2.5/cgi.py", line 609, in keys
    raise TypeError, "not indexable"
TypeError: not indexable

This workaround in sqlhtml.accepts() helps for me:

        if not ret and self.record and self.errors:
            for key in self.errors.keys():
                try:
                    if not request_vars.get(key,None) and
self.table[key].type=='upload' \
                            and self.record[key] and not
key+UploadWidget.ID_DELETE_SUFFIX in request_vars:
                        del self.errors[key]
                except TypeError:
                    pass

But IMO the real cause of non-indexable request_vars will be somewhere
else..

D
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkq9L54ACgkQ3oCkkciamVESjgCgmNMWX/7yS3oezscwSnjJFNx7
Zr4AoJLg+0Wv8isN08WWwZpWNgZN9UNq
=SlJu
-----END PGP SIGNATURE-----

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to