On Aug 25, 2010, at 8:11 AM, Joe Wakefield wrote:

> The assertion errors are blank, so I added some extra output:
> 
> -----IS_IMAGE STARTED-----
> filename: 1.png
> extension: png
> self.extensions: jpeg
> ERROR IN IS_IMAGE:
> 
> -----IS_IMAGE STARTED-----
> filename: llamas.jpg
> extension: jpg
> self.extensions: jpeg
> __jpeg called
> width, height: 400, 300
> new: users.photo.81f708977b7f7851.6c6c616d61732e6a7067.jpg    old:
> 
> -----IS_IMAGE STARTED-----
> filename: 1.png
> extension: png
> self.extensions: jpeg
> ERROR IN IS_IMAGE:
> new: users.photo.8ef32f83074cd5bf.312e706e67.png    old: users.photo.
> 81f708977b7f7851.6c6c616d61732e6a7067.jpg
> 
> -----IS_IMAGE STARTED-----
> filename: test.zip
> extension: zip
> self.extensions: jpeg
> ERROR IN IS_IMAGE:
> new: users.photo.a4b74cd11efaf711.746573742e7a6970.zip    old:
> users.photo.8ef32f83074cd5bf.312e706e67.png
> 
> This would suggest that the IS_IMAGE validator is working fine, and
> I'm guessing the problem would be in sqlform.accepts()?

My desk-check of IS_IMAGE suggested that it was OK, too. It could use a couple 
of documenting doctests, I think. 

You're deliberately restricting it to jpeg above, right? Hence the rejection of 
png?


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


Reply via email to