[Zope3-dev] Re: Existential question about BytesWidget v.s. ASCIIWidget

Jim Fulton jim at zope.com
Mon Jun 13 10:13:09 EDT 2005


Stéphane Brunet wrote:
> Derrick Hudson wrote:
> 
>> On Sun, Jun 12, 2005 at 08:20:36PM -0400, Stéphane Brunet wrote:
>> [... (read the thread if you want all the background info) ...]
>>
>> | What is the "raison d'être" of ASCIIWidget v.s. BytesWidget if they 
>> | expect the same type of input (plain ASCII text) and store it the 
>> same | type of fields?
>>
>> My interpretation is this:  BytesWidget will accept any byte in the
>> range 0x00 - 0xFF whereas the ASCIIWidget is intended to only accept
>> bytes in the range 0x20 - 0x7E and 0x09.  In other words I expect that
>> the ASCIIWidget will accept only printable characters from the ASCII
>> character set (IOW "text") but the BytesWidget will accept a sequence
>> of any arbitrary 8-bit value.
>>
>>  
>>
> That's what I thought... However, Bytes(Area)Widgets only accept ASCII 
> input, even if the Bytes widget accepts any bytes in the 0-255 range.

First, you are confusing schema definitions and widgets.  You should
start from the definitions of the field types.

As Derrick (sort of) suggested, Bytes fields are fields that contain
Python strings, as opposed to Text fields, which contain unicodes.
Bytes values can contain pretty much arbitrary string values.  For
example, a Bytes fields could contain image data.

ASCII fields contain only 7-bit ascii data. ASCII fields were introduced
in recognition that many Bytes fields were being used in cases of source
code where the desire was, mainly, to avoid unicode.

There are lots of schemas that are using Bytes that should probably
use ASCII or Text instead.  I would say that most or all occurrences
of BytesLine should use ASCIILine instead. Unfortunately there is no
ASCIILine. Sigh.

The widgets are probably out of sync with these definitions.
I suspect that the Bytes widgets behave the way they do because
they were developed before we had an ASCCII type.

It woul dbe great for someone to try to get this cleaned up. :)

Jim

-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org


More information about the Zope3-dev mailing list