[mod_python] ValueError with Flash 8 FileReference.upload(url)

Graham Dumpleton grahamd at dscpl.com.au
Sat Apr 22 23:49:51 EDT 2006


On 22/04/2006, at 8:33 AM, Alec Matusis wrote:

> Is there a way to read the request by lines in the filter, rather than
> trying to read the entire buffer?
> That way at least the text that I am trying to replace will come in  
> a single
> read, when I read that line.
>
> Or will it be to slow?

There is no way to read a line at a time.

All I can suggest is that you read through the complete recent thread  
about
filters as described in:

     http://www.modpython.org/pipermail/mod_python/2006-April/ 
020869.html

For thread view see:

     http://www.modpython.org/pipermail/mod_python/2006-April/ 
thread.html

In that thread it gives recipes for how to buffer up data until it is  
all received
so that it can be processed in one go, thus avoiding problems with  
partial
reads of data you are interested in.

In terms of whether it would be slow or not, I would suggest you just  
get
something working first that would work reliably and only then worry  
about
performance. In the greater scheme of things, your traffic for these  
sort of
posts may be so minimal that you could ignore that they incur slightly
greater overhead.

Graham

> -----Original Message-----
> From: Graham Dumpleton [mailto:grahamd at dscpl.com.au]
> Sent: Friday, April 21, 2006 3:24 PM
> To: Alec Matusis
> Cc: mod_python at modpython.org
> Subject: Re: [mod_python] ValueError with Flash 8  
> FileReference.upload(url)
>
> Actually there is another problem that only came to me later. That is
> that
> there is no guarantee with an input filter that you are going to  
> get the
> complete text you are trying to replace in one read even if it was
> written
> in one go by the client. This is because you are at the mercy of how
> blocking of data reads off the client socket works out. A patching of
> the
> util.FieldStorage class may be the only way around that.
>
> Graham
>
> On 21/04/2006, at 7:40 PM, Alec Matusis wrote:
>
>>  Yes, I got that.
>> Thanks, I tested it, all works well.
>>
>> I hope this filter does not tax the performance too much when I
>> submit large
>> files?
>>
>> -----Original Message-----
>> From: Graham Dumpleton [mailto:grahamd at dscpl.com.au]
>> Sent: Friday, April 21, 2006 2:39 AM
>> To: Alec Matusis
>> Cc: mod_python at modpython.org
>> Subject: Re: [mod_python] ValueError with Flash 8
>> FileReference.upload(url)
>>
>> Whoops.
>>
>>
>> On 21/04/2006, at 7:23 PM, Graham Dumpleton wrote:
>>
>>> A creative way of getting around the problem. I hadn't thought
>>> of using a filter. Some suggested changes below.
>>>
>>> On 21/04/2006, at 6:12 PM, Alec Matusis wrote:
>>>
>>>>
>>>> I figured out how to do this without changing mod_python source:
>>>>
>>>> I wrote a mod_python input filter:
>>>>
>>>> flashfilter.py:
>>>>
>>>> from mod_python import apache
>>>>
>>>> def inputfilter(filter):
>>>>     #this is a workaround flash 8 FileReference bug: Flash POST is
>>>> not
>>>> RFC-compliant as of Flash 8,0,22,0
>>>
>>>
>>>     if 'flashfileref' in parse_args(filter.req.args):
>>>       filter.pass_on()
>>>       return
>>
>> Logic wrong way around.
>>
>>      if 'flashfileref' not in parse_args(filter.req.args):
>>        filter.pass_on()
>>        return
>>
>> Graham



More information about the Mod_python mailing list