[Zope-dev] Pointless code in ZPublisher.HTTPRequest ?

Paul Winkler pw_lists at slinkp.com
Tue Aug 31 18:47:27 EDT 2004


On Tue, Aug 31, 2004 at 10:31:47PM +0200, Tino Wildenhain wrote:
> Am Di, den 31.08.2004 schrieb Paul Winkler um 19:08:
> > Can anyone enlighten me on what this is for?
> > >From ZPublisher.HTTPRequest.HTTPRequest.keys:
> ...
> > 
> > ** btw, this too smells a bit funny to me... why bother to keep a 
> > separate data structure in sync, when we could just do:
> > 
> >     for i in range(9):
> >         try:
> >             del(self.other['URL%d' % i])
> >             i += 1
> are you sure about the increment here?

Ugh, I sent that too quick.  Also I forgot to delete BASEN.
Maybe something more like this:

    def _resetURLS(self):
        """ Remove cached URLN and BASEN items.
        """
        other = self.other
        other['URL'] = '/'.join([other['SERVER_URL']] + self._script +
                            self._steps)
        for prefix in ('URL', 'BASE'):
            i = 0            
            while True:
                try:
                    del self.other['%s%d' % (prefix, i)]
                    i += 1
                except KeyError:
                    break


I just tried this on a fresh checkout of HEAD and all tests pass and 
everything seems to work normally.

Any interest in this little cleanup?
It seems pretty safe and pretty trivial to me...
-- 

Paul Winkler
http://www.slinkp.com


More information about the Zope-Dev mailing list