Opened 14 years ago

Closed 14 years ago

#2199 defect closed fixed (fixed)

Adaption of web2.iweb interfaces is broken

Reported by: Wilfredo Sánchez Vega Owned by:
Priority: highest Milestone: Web2-Gold-Master
Component: web2 Keywords:
Cc: Wilfredo Sánchez Vega Branch:


As of r18455, adaption of web2.iweb interfactes is broken in that it no longer raises TypeError when adaptions fails and instead returns None.

A change to SpecialAdaptInterfaceClass.__call__() appears to be the cause.

Change History (5)

comment:1 Changed 14 years ago by Wilfredo Sánchez Vega

Summary: Adaption of web2.iweb interfactes is brokenAdaption of web2.iweb interfaces is broken

Perhaps something more like:

# Is there a better way to do this than this funky extra class?
NotSpecified = object()
class SpecialAdaptInterfaceClass(interface.InterfaceClass):
    # A special adapter for IResource to handle the extra step of adapting
    # from IOldNevowResource-providing resources.
    def __call__(self, other, alternate=NotSpecified):
        if alternate == NotSpecified:
                return super(SpecialAdaptInterfaceClass, self).__call__(other)
            except TypeError:
            result = super(SpecialAdaptInterfaceClass, self).__call__(other, alternate)
            if result is not alternate:
                return result
        if alternate == NotSpecified:
            return IOldNevowResource(other)
        result = IOldNevowResource(other, alternate)
        if result is not alternate:
            return IResource(result)
        return alternate
IResource.__class__ = SpecialAdaptInterfaceClass

comment:2 Changed 14 years ago by Jean-Paul Calderone

Keywords: review added
Owner: Jean-Paul Calderone deleted

Ready for review in transitive-adaption-2199

comment:3 Changed 14 years ago by therve

Keywords: review removed
Owner: set to Jean-Paul Calderone

Looks good, greatly improves test coverage. I was only wondering if the tests wouldn't be better in test_compat than in test_server. Anyway it should be merged.

comment:4 Changed 14 years ago by Jean-Paul Calderone

Resolution: fixed
Status: newclosed

(In [18666]) Merge transitive-adaption-2199

Author: exarkun Reviewer: therve Fixes #2199

Add tests for various adaption behaviors related to IResource and fix the implementation of to make these new tests pass.

comment:5 Changed 9 years ago by <automation>

Owner: Jean-Paul Calderone deleted
Note: See TracTickets for help on using tickets.