[Biopython-dev] Last chance to claim Dispatch bug fix
Jeffrey Chang
jchang at smi.stanford.edu
Mon Apr 1 20:10:17 EST 2002
Please don't do that. If I understand correctly, you are having
problems with Martel.Parser._parse_elements because it is checking to
see if a class is an instance of Dispatch.Dispatcher. You are using a
ParserSupport._EventGenerator object that is decorating a _consumer
member that is a Dispatcher. Since _EventGenerator is not a
Dispatcher, the check in _parse_elements fails. You want it to
succeed because your _consumer can handle the Dispatcher calls. Thus,
you would like to patch _EventGenerator to expose the _consumer member
via a function call, and patch _parse_elements to call that function
to see whether the decorated object is a Dispatcher.
I don't think this is the right approach to solve the problem, because
it makes too many changes to the APIs to both _EventGenerator and
_parse_elements. This might be acceptable if it's a common enough
case, but I'm not convinced that it is.
The problem with adding new APIs is that they're hard to get rid of.
If you add a method to get the decorated object of _EventGenerator,
future implementations and subclasses of this object will have to also
implement this method, even if it's not a decorator. Plus, if you add
another check in _parse_elements, that method will have to do multiple
checks forever. In addition, any other method that checks to see
whether an object is a Dispatcher will have to do that check too. It
gets messy and bug-prone really fast.
Instead, you should create your own subclass of _EventGenerator that
also inherits from Dispatcher, so that you conform to the API that
_parse_elements is expecting.
Jeff
On Mon, Apr 01, 2002 at 03:17:54PM -0800, Cayte wrote:
> I posted a description of my fix. So I have a grren light to proceed?
> Cayte
> ----- Original Message -----
> From: "Jeffrey Chang" <jchang at smi.stanford.edu>
> To: "Cayte" <katel at worldpath.net>
> Cc: <biopython-dev at biopython.org>
> Sent: Thursday, March 28, 2002 9:03 PM
> Subject: Re: [Biopython-dev] Last chance to claim Dispatch bug fix
>
>
> > Hi Cayte,
> >
> > Could you please describe your fixes in a little more detail? For
> > example, I'm not sure what you're planning on doing with _consumer in
> > ParserSupport, or what problem it's trying to solve. Also, for
> > _consumer, are you referring to the member variable of the
> > EventGenerator or SGMLStrippingConsumer, or something else?
> >
>
More information about the Biopython-dev
mailing list