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

Paul Winkler pw_lists at slinkp.com
Tue Aug 31 20:33:02 EDT 2004


On Tue, Aug 31, 2004 at 06:47:27PM -0400, Paul Winkler wrote:
> 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:
(snip)

Further logging revealed an off-by-one error that resulted
IN NOTHINg getting cleared at all :-P
Here we go:

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


once again, tests pass and some poking around revealed nothing odd.

-- 

Paul Winkler
http://www.slinkp.com


More information about the Zope-Dev mailing list