[Web-SIG] about Py[Type]_Check in a WSGI implementation
Manlio Perillo
manlio_perillo at libero.it
Fri Oct 19 21:43:39 CEST 2007
Ian Bicking ha scritto:
> Manlio Perillo wrote:
>> The WSGI spec requires the response headers and sequence items to be,
>> respectively, List of Tuples and Strings.
>>
>> However only for the response headers it explicitly requires them to
>> be a Python List, i.e type(response_headers) is ListType.
>>
>> What about the other objects?
>>
>> In the current implementation of WSGI for Nginx I always use
>> Py[Type]_Check, and not Py[Type]_CheckExact.
>
> All of the types are required to be exactly as defined, not subclasses
> or None. But servers are not required to actually test this.
> wsgiref.validate does test for exactly these types, but it's acceptable
> for Nginx to just access the data without checking its exact type.
>
Ok, thanks.
However it is not a problem to use Py[Type]_Check instead of
Py[Type]_CheckExact (and it should not be slower), so if the types are
required to be exactly as defined I think it is better to do the exact
check.
In mod_wsgi for Nginx I'm doing a lot of checks (as an example I even
check if the write callable is called from within application iterable)
Manlio Perillo
More information about the Web-SIG
mailing list