Guard in file upload

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Guard in file upload

Sean P. DeNigris
Administrator
In Dynamic Web Development with Seaside - 10.7 File Uploads, the code has the following:
UploadForm>>receiveFile: aFile
    | file |
    aFile isNil ifTrue: [ ^ nil ].
...

The explanation says:
Note that it is possible to press the Send File button before selecting a file. The #receiveFile: method guards against this by checking that file is not nil.
However, I put a halt in the block, and hit the "Send file" button, and it seems this is never called:
        aFile isNil ifTrue: [
                self halt.
                self inform: 'No file!'].

Is this guard necessary?

Thanks.
Sean
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Guard in file upload

Philippe Marschall
2010/9/5 Sean P. DeNigris <[hidden email]>:

>
> In Dynamic Web Development with Seaside - 10.7 File Uploads, the code has the
> following:
> UploadForm>>receiveFile: aFile
>    | file |
>    aFile isNil ifTrue: [ ^ nil ].
> ...
>
> The explanation says:
>
> Note that it is possible to press the Send File button before selecting a
> file. The #receiveFile: method guards against this by checking that file is
> not nil.
>
> However, I put a halt in the block, and hit the "Send file" button, and it
> seems this is never called:
>        aFile isNil ifTrue: [
>                self halt.
>                self inform: 'No file!'].
>
> Is this guard necessary?

Nope you're right, it's not. WAUploadCallback >> #valueForField:
answers nil if there's not file and WAValueCallback >>
#evaluateWithArgument: has the nil guard.

Cheers
Philippe
_______________________________________________
seaside-dev mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev
Reply | Threaded
Open this post in threaded view
|

Re: Guard in file upload

Philippe Marschall
2010/9/6 Philippe Marschall <[hidden email]>:

> 2010/9/5 Sean P. DeNigris <[hidden email]>:
>>
>> In Dynamic Web Development with Seaside - 10.7 File Uploads, the code has the
>> following:
>> UploadForm>>receiveFile: aFile
>>    | file |
>>    aFile isNil ifTrue: [ ^ nil ].
>> ...
>>
>> The explanation says:
>>
>> Note that it is possible to press the Send File button before selecting a
>> file. The #receiveFile: method guards against this by checking that file is
>> not nil.
>>
>> However, I put a halt in the block, and hit the "Send file" button, and it
>> seems this is never called:
>>        aFile isNil ifTrue: [
>>                self halt.
>>                self inform: 'No file!'].
>>
>> Is this guard necessary?
>
> Nope you're right, it's not. WAUploadCallback >> #valueForField:
> answers nil if there's not file and WAValueCallback >>
> #evaluateWithArgument: has the nil guard.

The book and method comments are updated.

Cheers
Philippe
_______________________________________________
seaside-dev mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev
Reply | Threaded
Open this post in threaded view
|

Re: Guard in file upload

Sean P. DeNigris
Administrator
Philippe Marschall wrote
The book and method comments are updated.
Thanks.

Sean
Cheers,
Sean