how come i have to test an empty string field within a try|except block
like this:
try:
b = q.create_lecture_foldername!=None
except:
b = False
if b:
something
instead of the more straight forward:
if (q.create_lecture_foldername!=None):
something
because if i try the previous simpler approach, it blows giving me the
error:
if (usr.create_lecture_foldername!=None):
File "/opt/web-apps/web2py/gluon/dal.py", line 3851, in __getattr__
return self[key]
File "/opt/web-apps/web2py/gluon/dal.py", line 3842, in __getitem__
return dict.__getitem__(self, key)
KeyError: 'create_lecture_foldername'
same as if i try to use the len() method:
if (usr.create_lecture_foldername.len()>0):
File "/opt/web-apps/web2py/gluon/dal.py", line 3851, in __getattr__
return self[key]
File "/opt/web-apps/web2py/gluon/dal.py", line 3842, in __getitem__
return dict.__getitem__(self, key)
KeyError: 'create_lecture_foldername'
so isn't there a better way then the try|except block. lucas