[Web-SIG] Pre-PEP: Python Web Container Interface v1.0
Ng Pheng Siong
ngps at post1.com
Mon Dec 8 10:39:01 EST 2003
On Mon, Dec 08, 2003 at 09:57:34AM -0500, Phillip J. Eby wrote:
> >+1 for None.
> >
> >Zope is able to use REMOTE_USER if the web server sets it, e.g.,
>
> But what does it do if it's set to 'None'?
Let's see...
~/pkg/zope262/lib/python/ZPublisher$ egrep -i remote_user *.py
BaseRequest.py: elif request.environ.has_key('REMOTE_USER'):
BaseRequest.py: name=request.environ['REMOTE_USER']
HTTPRequest.py: 'REMOTE_USER' : 1,
Publish.py: if realm and not request.get('REMOTE_USER',None):
If it is None, Zope does nothing about it, I suppose.
ZServerSSL...
def get_environment(self, request):
env = zhttps0_handler.get_environment(self, request)
peer = request.channel.get_peer_cert()
if peer is not None:
env['REMOTE_USER'] = str(peer.get_subject())
return env
(Oh, ok, it's just a setter. I'd forgotten.)
ZServerSSL sets REMOTE_USER for RemoteUserFolder's consumption.
> Compatibility with the vast existing app framework code base demands that
> environ values *must* be strings, or else not present. (Guess I should add
> that to the spec.)
Looking at RemoteUserFolder:
name = request.environ.get('REMOTE_USER', None)
name = self.normalizeName(name)
#LOG('RemoteUserFolder', INFO, 'validate %s' % str(name) )
if name is None:
...
Well, the plural of `anecdote' is not `data' ;-), but it does seem to me
the following 2 styles will be dominant:
1)
x = dict.get('XX', None)
if x is None:
...
2)
if dict.has_key('XX'):
...
So I'm guessing it is not terribly important whether it is '' or None.
Cheers.
--
Ng Pheng Siong <ngps at netmemetic.com>
http://firewall.rulemaker.net -+- All Your Rulebase Are Belong To You[tm]
http://sandbox.rulemaker.net/ngps -+- Open Source Python Crypto & SSL
More information about the Web-SIG
mailing list