[Web-SIG] Unicode in Python 3

Henry Precheur henry at precheur.org
Sat Sep 19 22:05:58 CEST 2009


On Sat, Sep 19, 2009 at 07:14:23PM +0100, René Dudfield wrote:
> Yes, I think the callables will need a set method... rather than
> letting the middleware replace callables.
> 
> I think this could be used for middleware:
>   environ['SCRIPT_NAME'](set = "/bla/", urldecoding = False, encoding ='utf-8')
> 
> but then this(one callable) would probably be better ;)
>   environ(what='SCRIPT_NAME', set = "/bla/", urldecoding = False,
> encoding ='utf-8')
> 
> Since changing the middleware could potentially trigger the rest of
> the decoding.  In some situations you would want to avoid reading from
> the socket at all.  So middleware changing stuff would mean you would
> need to read from the socket(obviously you need to read stuff before
> changing it).
> 
> Why would you not want to read from the socket at all?  (wsgi 1.0
> makes these impossible)
>     - to block certain hosts by looking at their ip.
>     - you might just care about a connection, like any connection
> triggers an action.
>     - for load balancing
>     - to look at the port number, eg, to check if port 443 is used.
>     - if you are overloaded(dos), you want to drop the connection right away.
>     - ... others.
> 
> So allowing the server to avoid most processing before the application
> requests certain data could be a good thing.
> 
> So with middleware changing the environ, it means that all those
> callables need to be linked to allow the rest of them to know
> something has been changed.  So that when one thing is changed, it
> drops back to wsgi 1.0 behaviour - that is, some of the encoding is
> done just before any change is allowed.
> 
> Or maybe middleware has to call a environ['changing']() callable.
> Which could then trigger the callables internal transcoding and socket
> reading etc.
> 
> 
> I'm not sure if it will make middleware harder to use or not still.
> I'm working through the function Philip sent to see how it turns out,
> and will send an updated proposal after that.

All this is a lot of 'added functionality'. What made WSGI nice is that
it was using only basic Python types. We should try to simplify the
interface, not try to make it 'smarter' by adding clever features. Let
the frameworks do that.

-- 
  Henry Prêcheur


More information about the Web-SIG mailing list