I ended up with making a custom validator "IS_ALL" for the problem:
"IS_NULL_OR(IS_ALL([IS_XXX(..), IS_YYY(..), ..])" and it works. The alternatives could be to permit the follwoing interfaces, which need patches though: "IS_NULL_OR([IS_XXX(..), IS_YYY(..), ..])" or "[IS_NULL_OR(IS_XXX(..)), IS_NULL_OR(IS_YYY(..)), ..]" (the first one) What do you think? Thanks in advance, Kenji On 1月12日, 午後10:57, Massimo Di Pierro <[email protected]> wrote: > good catch. Let me think about this... > > On Jan 12, 1:12 am, kenji4569 <[email protected]> wrote: > > > > > > > > > I applied the follwing validators for upload fields in version 1.91.6: > > > requires = [ > > IS_NULL_OR(IS_UPLOAD_FILENAME(extension='pdf')), > > IS_NULL_OR(IS_LENGTH(1048576, 1024)), > > ] > > > Everything was fine until I used a SQLFORM object with an upload > > keyword for editing. > > > Then, a delete checkbox of an upload widget falsely disappeared which > > should be displayed with a link to the uploaded file. > > > This is the result of the code in UploadWidget class of gluon/ > > sqlhtml.py: > > > if requires == [] or isinstance(requires, IS_EMPTY_OR): > > inp = DIV(, ..., > > UploadWidget.ID_DELETE_SUFFIX), > > ...) > > > And, the next patch would tentatively fix the problem: > > > if (requires == [] or isinstance(requires, IS_EMPTY_OR) or > > (isinstance(requires, (list, tuple)) and > > reduce(lambda a,b:a&b, [isinstance(r, IS_EMPTY_OR) for r in > > requires]))): > > ... > > > But, I am not sure if the above patch is smart. > > Is there any way to implement such validation without patches nor > > custom validators?

