Please check if this is fixed in trunk and if the comment I added makes any sense.
Massimo On Aug 25, 10:59 am, Jonathan Lundell <jlund...@pobox.com> wrote: > On Aug 25, 2010, at 8:33 AM, Joe Wakefield wrote: > > > I'll do you one better. The problem is in "sqlhtml.py" at lines > > 909-917. It changes ret=False to ret=True if the field already has a > > value. > > Good catch. This is a case where a comment documenting the intent of this > hunk of code would come in handy for those of us reading it. The error is > cancelled under certain conditions, but what's the intent? > > > > > ======= > > ret, errors: False, <Storage {'photo': 'invalid image'}> > > new ret:False > > ======= > > ret, errors: True, <Storage {}> > > new ret:True > > new: users.photo.8a5327ab32003765.6c6c616d61732e6a7067.jpg old: > > ======= > > ret, errors: False, <Storage {'photo': 'invalid image'}> > > new ret:True > > new: users.photo.b6369c7a23ae4813.312e706e67.png old: users.photo. > > 8a5327ab32003765.6c6c616d61732e6a7067.jpg > > > On Aug 25, 10:17 am, mdipierro <mdipie...@cs.depaul.edu> wrote: > >> can you help me debug? > > >> in gluon/validators.py > > >> classIS_IMAGE: > >> def __call__(self,value): > >> .... > >> except: > >> return (value, self.error_message) > > >> replace last two lines with > > >> except Exception, e: > >> return (value, str(r)) > > >> what does the error say? > > >> On Aug 23, 4:06 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > >>> Something is wrong here > > >>> IS_IMAGE(extensions=('jpeg')) > > >>> should be > > >>> IS_IMAGE(extensions=('jpeg',)) > > >>> A tuple of one element must contain a comma. Not sure if that may be > >>> the cause of your problem. > > >>> On Aug 23, 3:16 pm, Joe Wakefield <coffeeburr...@gmail.com> wrote: > > >>>> I was also experiencing this issue, but found that rebuilding the > >>>> database only worked until the first valid upload, after which it is > >>>> broken again. > > >>>> In my case, I am using: > >>>> Field('photo', 'upload', uploadfield='photo_data', > >>>> requires=IS_IMAGE(extensions=('jpeg'))), > >>>> Field('photo_data', 'blob', requires=IS_IMAGE(extensions=('jpeg'))), > > >>>> And was using SQLFORM to display the update form. > > >>>> When I first added this, it was accepting absolutely everything (pdf, > >>>> odt, zip) as an upload. I deleted my database entirely, and had it > >>>> rebuilt. I first noticed that it started rejecting non-image uploads. > >>>> However, once I had uploaded an image, all subsequent uploads of non- > >>>> image types were allowed again. A second database build showed the > >>>> exact same behaviour; proper rejection until the first valid upload. > > >>>> I then made a backup of my web2py folder, and extracted today's > >>>> nightly build over my folder. Rebuilding my database one last time, it > >>>> shows the exact same behaviour. > > >>>> On Jul 11, 2:56 pm, Rob <r...@rmdashr.com> wrote: > > >>>>> I just recently added: > > >>>>> db.Item.image.requires =IS_IMAGE() > > >>>>> The records that existed prior to adding this line does not obey > >>>>> theIS_IMAGE() (ie: they still allow me to upload a PDF). All new > >>>>> records > >>>>> created DO work - they force me to select an image or else they show > >>>>> an error. > > >>>>> steps to reproduce (untested) > >>>>> 1) create DB > >>>>> db.define_table('Item', > >>>>> Field('description'), > >>>>> Field('need', 'boolean'), > >>>>> Field('image', 'upload')) > > >>>>> 2) add rows to the table > >>>>> 3) add rules: > >>>>> db.Item.category.requires = IS_IN_DB(db, db.Category.id,'%(name)s') > >>>>> db.Item.description.requires = IS_NOT_EMPTY() > >>>>> db.Item.image.requires =IS_IMAGE() > > >>>>> 4) go back to the rows you added to the Item table and add non-image > >>>>> files - notice it works > > >>>>> Does that help? > > >>>>> On Jul 11, 11:42 am, mdipierro <mdipie...@cs.depaul.edu> wrote: > > >>>>>> Please tell us more. When do you get an error? What is the error? > > >>>>>> On 11 Lug, 11:57, Rob <r...@rmdashr.com> wrote: > > >>>>>>> This issue only happens for records that were created before I added > >>>>>>> the .requires fields. Error handling on new records works as > >>>>>>> expected... so... is it still a bug? > > >>>>>>> On Jul 11, 9:15 am, Rob <r...@rmdashr.com> wrote: > > >>>>>>>> db.define_table('Category', > >>>>>>>> Field('name')) > > >>>>>>>> db.define_table('Item', > >>>>>>>> Field('category', db.Category), > >>>>>>>> Field('description'), > >>>>>>>> Field('need', 'boolean'), > >>>>>>>> Field('image', 'upload')) > > >>>>>>>> db.Item.category.requires = IS_IN_DB(db, db.Category.id) > >>>>>>>> db.Item.description.requires = IS_NOT_EMPTY() > >>>>>>>> db.Item.image.requires =IS_IMAGE() > > >>>>>>>> def details(): > >>>>>>>> item = request.args(0) > >>>>>>>> form = crud.update(db.Item, item, next=URL(r=request, args=item)) > >>>>>>>> return dict(form=form) > > >>>>>>>> It allows me to upload PDFs and flashes 'record updated'