[Medusa-dev] composite_producer bug?

Giles Brown giles_brown@hotmail.com
Thu Oct 24 10:05:14 2002


Hello,

Reasons why this mail might be redundant:
- Only just subscribed to this list.
- Couldn't to sourceforge bug list (why? I don't know, got a 404)

I downloaded the medusa-0.5.2.tar from

http://oedipus.sourceforge.net/medusa/

and found that I was getting a problem serving my pages.  Only a
portion of the content was getting served.

After some investigation I tracked the problem down (I believe) to
the medusa.producers.composite_producer class.

In an old Sam Rushing era copy of the medusa I had lying about I
noticed that the medusa.http_server.http_request class initialised
self.outgoing with a medusa.http_server.fifo() instance.
At some point has been changed to use a plain list instead, but
this list is being passed to a medusa.producers.composite_producer
in the medusa.http_server.http_request.done method which is still
expecting an object with the medusa.http_server.fifo interface.

code from medusa-0.5.2.tar:medusa-0.5.2/producers.py ->

class composite_producer:
    "combine a fifo of producers into one"
    def __init__ (self, producers):
        self.producers = producers

    def more (self):
        while len(self.producers):
            p = self.producers.pop(0)
                              ^^^ (1)
            d = p.more()
            if d:
                return d
            else:
                self.producers.pop()
                              ^^^ (2)
        else:
            return ''


(1) This used to be p = self.producers.first().  Which did not remove
the producer from the head of the list.  Here we end up removing
the producer even if it has more to produce (which was the cause
of my problem).

(2) The fifo defines pop() as removing head of the list that it wraps.
For a list the default pop index is the tail of the list so we are
removing the wrong producer.

Options seem to be:
1) Look to ensure that composite_producer is expecting a list (interface) 
and not a fifo (interface).  Scanning the medusa code
composite_producer is only used in one other place *with an
http_server.fifo*.  This is in auth_handler.py.  But what about
compatibility with other code using current composite_producer.
2) Write a new composite_list_producer that is used (currently
only by http_request) to produce from a list.  Change the
composite_producer back to using http_server.fifo() interface.
3) Change http_server.http_request back to using http_server.fifo()
and change composite_producer back to using http_server.fifo()
interface (i.e. .first() and not .pop(0)).

Apologies if these things have already been discussed.

Best regards,
Giles Brown

_________________________________________________________________
Unlimited Internet access for only $21.95/month.  Try MSN! 
http://resourcecenter.msn.com/access/plans/2monthsfree.asp