Commit graph

83 commits

Author SHA1 Message Date
Lance Stout
75584d7ad7 Remap old method names in a better way.
This should prevent some reference cycles that will cause garbage
collection issues.
2011-02-14 13:49:43 -05:00
Lance Stout
0d32638379 XMPPError exceptions can keep a stanza's contents.
This allows exceptions to include the original
content of a stanza in the error response by including
the parameter clear=False when raising the exception.
2011-02-11 15:20:26 -05:00
Lance Stout
35ef8f9090 Make stanza.plugins an OrderedDict.
This allows you to determine the order in which substanzas
were added in the original XML.
2011-01-27 16:01:35 -05:00
Lance Stout
0c8a8314b2 Cleanup for stanzabase.
Use stanza.values instead of _get/set_stanza_values where used.

ElementBase stanzas can now use .tag

May use class method tag_name() for stanza classes.

ElementBase now has .clear() method.
2011-01-26 11:27:41 -05:00
Lance Stout
4e757c2b56 Upgraded how subitem works.
May now use register_stanza_plugin(Foo, Bar, iterable=True)
to add to the set of stanza classes used for iterable
substanzas. It is no longer necessary to manually specify
the contents of subitem if the new method is used.
2011-01-26 10:04:36 -05:00
Lance Stout
da332365d4 Make extending stanza objects nicer.
A stanza object may add is_extension = True to its class definition
to provide a single new interface to a parent stanza.

For example:

import sleekxmpp
from sleekxmpp import Iq
from sleekxmpp.xmlstream import ElementBase, register_stanza_plugin, ET

class Foo(ElementBase):
    """
    Test adding just an attribute to a parent stanza.

    Adding subelements works as expected.
    """
    is_extension = True
    interfaces = set(('foo',))
    plugin_attrib = 'foo'

    def setup(self, xml):
        # Don't include an XML element in the parent stanza
        # since we're adding just an attribute.
        # If adding a regular subelement, no need to do this.
        self.xml = ET.Element('')

    def set_foo(self, val):
        self.parent()._set_attr('foo', val)

    def get_foo(self):
        return self.parent()._get_attr('foo')

    def del_foo(self):
        self.parent()._del_attr('foo')

register_stanza_plugin(Iq, Foo)

i1 = Iq()
i2 = Iq(xml=ET.fromstring("<iq xmlns='jabber:client' foo='bar' />"))

>>> i1['foo'] = '3'
>>> i1
'3'
>>> i1
'<iq id="0" foo="3" />'
>>> i2
'<iq id="0" foo="bar" />'
>>> i2['foo']
'bar'
>>> del i2['foo']
>>> i2
'<iq id="0" />'
2011-01-19 19:49:13 -05:00
Lance Stout
f474d378ef Add support for using xml:lang values.
Support is only for adding literal XML content
to stanzas. Full support for things like multiple
message bodies with different xml:lang values is
still in the works.
2010-12-07 23:07:40 -05:00
Lance Stout
4fb77ac878 Logging no longer uses root logger.
Each module should now log into its own logger.
2010-11-06 01:28:59 -04:00
Lance Stout
4375ac7d8b Underscore names by default.
Stanza objects now accept the use of underscored names.

The CamelCase versions are still available for backwards compatibility,
but are discouraged.

The property stanza.values now maps to the old getStanzaValues and
setStanzaValues, in addition to _set_stanza_values and
_get_stanza_values.
2010-10-17 22:04:42 -04:00
Lance Stout
e02ffe8547 Corrected test errors.
There was a bug in the XML compare method.
2010-10-07 19:42:28 -04:00
Lance Stout
c294c1a85c More PEP8 compliance cleanups.
Cleaned up the atom entry stanza.
2010-10-06 15:12:39 -04:00
Lance Stout
aebd115ba2 A few cleanups to make things simpler. 2010-09-01 14:20:34 -04:00
Lance Stout
3749c1b88c Fixed ElementBase.match to match using sub_interface elements. 2010-08-30 17:12:10 -04:00
Lance Stout
998741b87e Fixed typos in ElementBase._fix_ns 2010-08-30 15:25:59 -04:00
Lance Stout
9c62bce206 Updated ElementBase.match to respect namespaces with slashes.
Required adding option to _fix_ns to not propagate namespaces to child elements.
2010-08-30 14:55:30 -04:00
Lance Stout
bb6f4af8e2 Added unit tests for StanzaBase. 2010-08-27 12:22:35 -04:00
Lance Stout
a2c515bc97 Updated StanzaBase with documentation. 2010-08-27 11:07:20 -04:00
Lance Stout
ca6ce26b0d Added comments to _fix_ns to clarify the cleaning procedure. 2010-08-26 18:40:58 -04:00
Lance Stout
00d7952001 Fixed ElementBase._fix_ns and related methods to respect namespaces which contain forward slashes. 2010-08-26 18:18:00 -04:00
Lance Stout
56766508b3 Fixed indentation in StanzaBase. 2010-08-26 14:19:36 -04:00
Lance Stout
5c59f5baca Clarify ElementBase documentation. 2010-08-26 14:07:09 -04:00
Lance Stout
e16b37d2be Fixed line lengths in ElementBase to comply with PEP8. 2010-08-26 13:55:23 -04:00
Lance Stout
d68bc2ba07 Finished the update of ElementBase with docs and unit tests.
Corrected bugs in equality comparisons between stanzas.
2010-08-26 13:49:36 -04:00
Lance Stout
10298a6eab Updated the remaining ElementBase methods.
Remaining ElementBase todos:
    Write the class documentation for ElementBase.
    Write unit tests for the __magic__ methods.
2010-08-26 10:08:22 -04:00
Lance Stout
a3580dcef9 Fixed ElementBase.match to respect namespaces. 2010-08-25 14:54:09 -04:00
Lance Stout
1eaa9cb28c Updated ElementBase.match and added unit tests. 2010-08-25 14:40:16 -04:00
Lance Stout
5d458bf6c2 Updated ElementBase._delSub and added unit tests.
_delSub can now accept a path and will optionally remove any empty parent elements after deleting the target elements.
2010-08-25 10:52:07 -04:00
Lance Stout
2fa58a74ab Fixed indenting issue. 2010-08-24 09:44:09 -04:00
Lance Stout
c8f406d1b3 Updated ElementBase._setSubText and added unit tests.
_setSubText can now handle elements specified by an XPath expression, and
will build up the element tree as needed, reusing an existing elements in
the path.
2010-08-24 09:37:42 -04:00
Lance Stout
203986dd7c Updated ElementBase._getSubText and added unit tests.
Also added ElementBase._fix_ns() to apply the stanza namespace to elements that don't have a namespace.
2010-08-24 08:55:37 -04:00
fritzy
345656926e added form compatibility with old api, stanzas now bool() to True on 2.x, jid attributes will return '' if not set 2010-08-21 22:48:43 +00:00
Lance Stout
8a0616b3e0 Updated ElementBase methods _getAttr, _setAttr, and _delAttr with docs and tests. 2010-08-19 20:41:26 -04:00
Lance Stout
b71cfe0492 Small cleanup in ElementBase.__setitem__ 2010-08-19 19:14:18 -04:00
Lance Stout
fac3bca1f6 Updated ElementBase.__delitem__ and added unit tests. 2010-08-19 19:11:12 -04:00
Lance Stout
e4240dd593 Updated ElementBase.__setitem__ and added unit tests. 2010-08-19 14:21:58 -04:00
Lance Stout
2f6f4fc16d Updated ElementBase.__getitem__ with docs and unit tests. 2010-08-13 21:33:11 -04:00
Lance Stout
fe49b8c377 Updated getStanzaValues and setStanzaValues with docs and unit tests. 2010-08-13 20:05:24 -04:00
Lance Stout
b580a3138d Updated ElementBase.enable and ElementBase.initPlugin 2010-08-13 12:51:07 -04:00
Lance Stout
c20fab0f6c Updated ElementBase.setup, and added unit tests. 2010-08-13 12:24:47 -04:00
Lance Stout
415520200e Updated ElementBase.__init__ 2010-08-13 10:26:33 -04:00
Lance Stout
747001d33c Adjust first level indenting in ElementBase to prepare for cleanup. 2010-08-13 10:15:52 -04:00
Lance Stout
b0fb205c16 Updated registerStanzaPlugin and the XML test type. 2010-08-13 10:12:51 -04:00
Lance Stout
4b52007e8c Cleaned stanzabase imports. 2010-08-12 23:24:09 -04:00
Lance Stout
e077204a16 Replaced the ToString class with a tostring function.
The sleekxmpp.xmlstream.tostring and sleekxmpp.xmlstream.tostring26 packages
have been merged to sleekxmpp.xmlstream.tostring. The __init__.py file will
import the appropriate tostring function depending on the Python version.

The setup.py file has been updated with the package changes.

ElementBase is now a direct descendent of object and does not subclass ToString.

Stanza objects now return their XML contents for __repr__.
2010-08-05 20:26:41 -04:00
Lance Stout
1cedea2804 Added optional default value to _getAttr. 2010-07-30 14:11:24 -04:00
Lance Stout
d148f633f3 Modified ElementBase _getSubText, _setSubText, and _delSubText to
use the namespace in a tag name if one is given and to use
self.namespace otherwise.
2010-07-29 11:04:21 -04:00
Nathan Fritz
2b6454786a Merge branch 'experimental' of git@github.com:fritzy/SleekXMPP into experimental 2010-07-26 18:13:54 -07:00
Nathan Fritz
a349a2a317 removed jid from stanzabase to external file 2010-07-26 18:13:34 -07:00
Lance Stout
c8989c04f3 Replaced traceback calls to use logging.exception where applicable. 2010-07-26 21:02:25 -04:00
Joe Hildebrand
d70a6e6f32 Issue 26. Only set from address in reply() for components 2010-07-20 13:55:48 -07:00