can you help me debug?

in gluon/validators.py

class IS_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'

Reply via email to