summaryrefslogtreecommitdiff
path: root/docs/xmpp_tdg.rst
diff options
context:
space:
mode:
Diffstat (limited to 'docs/xmpp_tdg.rst')
-rw-r--r--docs/xmpp_tdg.rst46
1 files changed, 23 insertions, 23 deletions
diff --git a/docs/xmpp_tdg.rst b/docs/xmpp_tdg.rst
index 3d12b1b6..b14fd9e1 100644
--- a/docs/xmpp_tdg.rst
+++ b/docs/xmpp_tdg.rst
@@ -1,20 +1,20 @@
Following *XMPP: The Definitive Guide*
======================================
-SleekXMPP was featured in the first edition of the O'Reilly book
+Slixmpp was featured in the first edition of the O'Reilly book
`XMPP: The Definitive Guide <http://oreilly.com/catalog/9780596521271/>`_
by Peter Saint-Andre, Kevin Smith, and Remko Tronçon. The original source code
for the book's examples can be found at http://github.com/remko/xmpp-tdg. An
updated version of the source code, maintained to stay current with the latest
-SleekXMPP release, is available at http://github.com/legastero/xmpp-tdg.
+Slixmpp release, is available at http://github.com/legastero/xmpp-tdg.
-However, since publication, SleekXMPP has advanced from version 0.2.1 to version
+However, since publication, Slixmpp has advanced from version 0.2.1 to version
1.0 and there have been several major API changes. The most notable is the
introduction of :term:`stanza objects <stanza object>` which have simplified and
standardized interactions with the XMPP XML stream.
What follows is a walk-through of *The Definitive Guide* highlighting the
-changes needed to make the code examples work with version 1.0 of SleekXMPP.
+changes needed to make the code examples work with version 1.0 of Slixmpp.
These changes have been kept to a minimum to preserve the correlation with
the book's explanations, so be aware that some code may not use current best
practices.
@@ -36,7 +36,7 @@ Updated Code
.. code-block:: python
def handleIncomingMessage(self, message):
- self.xmpp.sendMessage(message["from"], message["body"])
+ self.xmpp.send_message(message["from"], message["body"])
`View full source <http://github.com/legastero/xmpp-tdg/blob/master/code/EchoBot/EchoBot.py>`_ |
`View original code <http://github.com/remko/xmpp-tdg/blob/master/code/EchoBot/EchoBot.py>`_
@@ -47,7 +47,7 @@ Example 14-1. (Page 215)
**CheshiR IM bot implementation.**
The main event handling method in the Bot class is meant to process both message
-events and presence update events. With the new changes in SleekXMPP 1.0,
+events and presence update events. With the new changes in Slixmpp 1.0,
extracting a CheshiR status "message" from both types of stanzas
requires accessing different attributes. In the case of a message stanza, the
``"body"`` attribute would contain the CheshiR message. For a presence event,
@@ -72,21 +72,21 @@ Updated Code
.. code-block:: python
def handleIncomingXMPPEvent(self, event):
- msgLocations = {sleekxmpp.stanza.presence.Presence: "status",
- sleekxmpp.stanza.message.Message: "body"}
+ msgLocations = {slixmpp.stanza.presence.Presence: "status",
+ slixmpp.stanza.message.Message: "body"}
message = event[msgLocations[type(event)]]
user = self.backend.getUserFromJID(event["from"].jid)
if user is not None:
self.backend.addMessageFromUser(message, user)
-
+
def handleMessageAddedToBackend(self, message) :
body = message.user + ": " + message.text
htmlBody = "<p><a href='%(uri)s'>%(user)s</a>: %(message)s</p>" % {
"uri": self.url + "/" + message.user,
"user" : message.user, "message" : message.text }
for subscriberJID in self.backend.getSubscriberJIDs(message.user) :
- self.xmpp.sendMessage(subscriberJID, body, mhtml=htmlBody)
+ self.xmpp.send_message(subscriberJID, body, mhtml=htmlBody)
`View full source <http://github.com/legastero/xmpp-tdg/blob/master/code/CheshiR/Bot.py>`_ |
`View original code <http://github.com/remko/xmpp-tdg/blob/master/code/CheshiR/Bot.py>`_
@@ -102,7 +102,7 @@ Example 14-3. (Page 217)
The main difference for the configurable IM bot is the handling for the
data form in ``handleConfigurationCommand``. The test for equality
-with the string ``"1"`` is no longer required; SleekXMPP converts
+with the string ``"1"`` is no longer required; Slixmpp converts
boolean data form fields to the values ``True`` and ``False``
automatically.
@@ -145,7 +145,7 @@ Example 14-4. (Page 220)
Like several previous examples, a needed change is to replace
``subscription["from"]`` with ``subscription["from"].jid`` because the
-``BaseXMPP`` method ``makePresence`` requires the JID to be a string.
+``BaseXMPP`` method ``make_presence`` requires the JID to be a string.
A correction needs to be made in ``handleXMPPPresenceProbe`` because a line was
left out of the original implementation; the variable ``user`` is undefined. The
@@ -154,7 +154,7 @@ JID of the user can be extracted from the presence stanza's ``from`` attribute.
Since this implementation of CheshiR uses an XMPP component, it must
include a ``from`` attribute in all messages that it sends. Adding the
``from`` attribute is done by including ``mfrom=self.xmpp.jid`` in calls to
-``self.xmpp.sendMessage``.
+``self.xmpp.send_message``.
Updated Code
~~~~~~~~~~~~
@@ -162,19 +162,19 @@ Updated Code
.. code-block:: python
def handleXMPPPresenceProbe(self, event) :
- self.xmpp.sendPresence(pto = event["from"])
+ self.xmpp.send_presence(pto = event["from"])
def handleXMPPPresenceSubscription(self, subscription) :
if subscription["type"] == "subscribe" :
userJID = subscription["from"].jid
- self.xmpp.sendPresenceSubscription(pto=userJID, ptype="subscribed")
- self.xmpp.sendPresence(pto = userJID)
- self.xmpp.sendPresenceSubscription(pto=userJID, ptype="subscribe")
+ self.xmpp.send_presence_subscription(pto=userJID, ptype="subscribed")
+ self.xmpp.send_presence(pto = userJID)
+ self.xmpp.send_presence_subscription(pto=userJID, ptype="subscribe")
def handleMessageAddedToBackend(self, message) :
body = message.user + ": " + message.text
for subscriberJID in self.backend.getSubscriberJIDs(message.user) :
- self.xmpp.sendMessage(subscriberJID, body, mfrom=self.xmpp.jid)
+ self.xmpp.send_message(subscriberJID, body, mfrom=self.xmpp.jid)
`View full source <http://github.com/legastero/xmpp-tdg/blob/master/code/CheshiR/SimpleComponent.py>`_ |
`View original code <http://github.com/remko/xmpp-tdg/blob/master/code/CheshiR/SimpleComponent.py>`_
@@ -192,7 +192,7 @@ After applying the changes from Example 14-4 above, the registrable component
implementation should work correctly.
.. tip::
- To see how to implement in-band registration as a SleekXMPP plugin,
+ To see how to implement in-band registration as a Slixmpp plugin,
see the tutorial :ref:`tutorial-create-plugin`.
`View full source <http://github.com/legastero/xmpp-tdg/blob/master/code/CheshiR/RegistrableComponent.py>`_ |
@@ -203,13 +203,13 @@ Example 14-7. (Page 225)
**Extended CheshiR IM server component implementation.**
.. note::
- Since the CheshiR examples build on each other, see previous
+ Since the CheshiR examples build on each other, see previous
sections for corrections to code that is not marked as new in the book
example.
While the final code example can look daunting with all of the changes
made, it requires very few modifications to work with the latest version of
-SleekXMPP. Most differences are the result of CheshiR's backend functions
+Slixmpp. Most differences are the result of CheshiR's backend functions
expecting JIDs to be strings so that they can be stripped to bare JIDs. To
resolve these, use the ``jid`` attribute of the JID objects. Also,
references to ``"message"`` and ``"jid"`` attributes need to
@@ -239,11 +239,11 @@ Updated Code
userJID = subscription["from"].jid
user = self.backend.getUserFromJID(userJID)
contactJID = subscription["to"]
- self.xmpp.sendPresenceSubscription(
+ self.xmpp.send_presence_subscription(
pfrom=contactJID, pto=userJID, ptype="subscribed", pnick=user)
self.sendPresenceOfContactToUser(contactJID=contactJID, userJID=userJID)
if contactJID == self.componentDomain :
self.sendAllContactSubscriptionRequestsToUser(userJID)
`View full source <http://github.com/legastero/xmpp-tdg/blob/master/code/CheshiR/Component.py>`_ |
-`View original code <http://github.com/remko/xmpp-tdg/blob/master/code/CheshiR/Component.py>`_
+`View original code <http://github.com/remko/xmpp-tdg/blob/master/code/CheshiR/Component.py>`_