From ece9a51201cc0b3e2add187293b60c6ae35832b1 Mon Sep 17 00:00:00 2001 From: <brian@svn.zope.org> Date: Fri, 12 Nov 1999 18:15:53 +0000 Subject: [PATCH] Fixed REQUEST.get() to behave like a dict.get(). --- lib/python/ZPublisher/HTTPRequest.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/python/ZPublisher/HTTPRequest.py b/lib/python/ZPublisher/HTTPRequest.py index e3df4512b..9b498f973 100644 --- a/lib/python/ZPublisher/HTTPRequest.py +++ b/lib/python/ZPublisher/HTTPRequest.py @@ -83,7 +83,7 @@ # ############################################################################## -__version__='$Revision: 1.25 $'[11:-2] +__version__='$Revision: 1.26 $'[11:-2] import regex, sys, os, string from string import lower, atoi, rfind, split, strip, join, upper, find @@ -684,6 +684,7 @@ class HTTPRequest(BaseRequest): name='HTTP_%s' % name return environ.get(name, default) + def __getitem__(self,key, default=_marker, # Any special internal marker will do URLmatch=regex.compile('URL[0-9]+$').match, @@ -757,7 +758,10 @@ class HTTPRequest(BaseRequest): raise KeyError, key - __getattr__=get=__getitem__ + __getattr__=__getitem__ + + def get(self, key, default=None): + return self.__getitem__(key, default) def has_key(self, key): try: self[key] -- 2.30.9