-# Multiple inheritance makes my inner Java nerd cry. Why can't I just
-# add arbitrary attributes to list or str objects?! Guido, we need to
-# talk.
-class TwitterJsonResponse(list, TwitterResponse):
- __doc__ = """Twitter JSON Response
- """ + TwitterResponse.__doc__
-class TwitterXmlResponse(str, TwitterResponse):
- __doc__ = """Twitter XML Response
- """ + TwitterResponse.__doc__
+def wrap_response(response, headers):
+ response_typ = type(response)
+ if response_typ is bool:
+ # HURF DURF MY NAME IS PYTHON AND I CAN'T SUBCLASS bool.
+ response_typ = int
+
+ class WrappedTwitterResponse(response_typ, TwitterResponse):
+ __doc__ = TwitterResponse.__doc__
+
+ def __init__(self, response, headers):
+ response_typ.__init__(self, response)
+ TwitterResponse.__init__(self, headers)
+ def __new__(cls, response, headers):
+ return response_typ.__new__(cls, response)
+
+
+ return WrappedTwitterResponse(response, headers)
+