Rev | Line | |
---|
[8] | 1 | # -*- test-case-name: wokkel.test.test_compat -*- |
---|
| 2 | # |
---|
[96] | 3 | # Copyright (c) Twisted Matrix Laboratories. |
---|
[8] | 4 | # See LICENSE for details. |
---|
| 5 | |
---|
[160] | 6 | """ |
---|
| 7 | Compatibility module to provide backwards compatibility with Twisted features. |
---|
| 8 | """ |
---|
| 9 | |
---|
[200] | 10 | from __future__ import division, absolute_import |
---|
[160] | 11 | |
---|
[165] | 12 | from twisted.python.deprecate import deprecatedModuleAttribute |
---|
| 13 | from twisted.python.versions import Version |
---|
[34] | 14 | from twisted.words.protocols.jabber import xmlstream |
---|
[63] | 15 | |
---|
| 16 | class IQ(xmlstream.IQ): |
---|
| 17 | def __init__(self, *args, **kwargs): |
---|
| 18 | # Make sure we have a reactor parameter |
---|
| 19 | try: |
---|
| 20 | reactor = kwargs['reactor'] |
---|
| 21 | except KeyError: |
---|
| 22 | from twisted.internet import reactor |
---|
| 23 | kwargs['reactor'] = reactor |
---|
| 24 | |
---|
| 25 | # Check if IQ's init accepts the reactor parameter |
---|
| 26 | try: |
---|
| 27 | xmlstream.IQ.__init__(self, *args, **kwargs) |
---|
| 28 | except TypeError: |
---|
| 29 | # Guess not. Remove the reactor parameter and try again. |
---|
| 30 | del kwargs['reactor'] |
---|
| 31 | xmlstream.IQ.__init__(self, *args, **kwargs) |
---|
| 32 | |
---|
| 33 | # Patch the XmlStream instance so that it has a _callLater |
---|
| 34 | self._xmlstream._callLater = reactor.callLater |
---|
[160] | 35 | |
---|
| 36 | |
---|
| 37 | |
---|
[200] | 38 | __all__ = ['IQ'] |
---|
Note: See
TracBrowser
for help on using the repository browser.