Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Real-time collaborative editing for Plone
Python JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.



jarn.xmpp.collaboration defines a protocol to do real-time collaborative editing through XMPP and provides:

  • a generic overridable implementation of the server component.
  • a Plone-specific implementation (server component and javascript client).
  • adapters for basic Plone content types (Pages and News Items).

It is part of a suite of packages aiming to provide XMPP services to Plone. The other two packages are

  • jarn.xmpp.twisted, provides XMPP-specific protocol implementation for twisted.
  • jarn.xmpp.core provides facilities for presence, messaging, chatting and microblogging.


Please see jarn.xmpp.core for details on setting up your Plone site and XMPP server. If you are not using the recipe included in jarn.xmpp.buildout you will need to configure your ejabberd to allow connections from the collaboration component. For ejabberd this is done by including the following in your config file:

{{5347, {0,0,0,0} }, ejabberd_service, [
  {access, all},
  {shaper_rule, fast},
  {ip, {127, 0, 0, 1}},
  {hosts, ["collaboration.localhost"],
   [{password, "secret"}]

The instance that is going to be running the xmpp component should include the component.zcml. You can do this in your buildout:

zcml-additional =
  <configure xmlns="">
      <include package="jarn.xmpp.twisted" file="reactor.zcml" />
      <include package="jarn.xmpp.collaboration" file="component.zcml" />

Finally you will need to "activate" the product in the Plone control panel. After doing so, please edit the registry settings and in particular:

  • jarn.xmpp.collaborationJID is the Jabber id of the collaborative editing service component. Essentially if myserver is your XMPP domain collaboration.myserver is a good name. This should match the name you gave to ejabberd, see above. Default is collaboration.localhost.
  • jarn.xmpp.collaborationPassword is the password the component will use to connect to your xmpp server, see above. Default is secret.
  • jarn.xmpp.collaborationPort is the port that your XMPP server allows components to connect to, see above. Default is 5347.


Using jarn.xmpp.collaboration is easy once you have gotten over setting it up. There are no special views to use when you collaboratively edit content. If an adapter to ICollaborativelyEditable exists for your content then accessing its edit form will allow multiple users to edit simultaneously.

Out of the box there exist adapters for archetypes as well as dexterity-based content types. For AT content types, fields that implement IStringField or ITextField will automatically get collaborative editing support. For Dexterity the fields that will be automatically included are those that provide ITextLine, IText or IRichText regardless of the behavior by which they are defined. Note that the javascript client assumes that TinyMCE is used. Collaboration on rich text fields will not work with Kupu.

Protocol specification.


In order to initiate a collaborative editing session, the party sends a presence stanza to the server component indicating on which node he wishes to work on. The party MUST specify the node attribute in the query element:

<presence from='' to=''>
    <query xmlns='' node='collab-node'/>

Upon receipt a message stanza is sent to anyone else who might be editing the same node notifying them of the new participant:

<message from='' to=''>
    <x xmlns=''>
        <item action='user-joined' node='collab-node' user=''/>

The newly joined user also receives a similar notification about existing users

<message from='' to=''>
    <x xmlns=''>
        <item action='user-joined' node='collab-node' user=''/>

To complete the initialization the new party MUST request the current version of the node from the server:

<iq id='123' from='' to='' type='get'>
    <shadowcopy xmlns='' node='collab-node'/>

To which the server replies providing his current copy of the text:

<iq id='123' from='' to=''  type='result'>
     <shadowcopy xmlns='' node='collab-node'>Hello world</shadowcopy>

In case the node does not exist, or the user has no privileges granting him access, the server MUST reply with an error, for instance:

<iq id='123' from='' to='' type='error'>
    <error xmlns=''>Unauthorized</error>

Editing cycle

When a party edits the text, it notifies the server by sending an iq stanza of type set. The stanza contains one patch element which MUST specify the node they apply to, and in their body contain the patch created by the Diff-Match-Patch algorithm in text format. For instance if the text changed from "Hello world" to "Hello world, have a nice day!" the message would be:

<iq id='234' from='' to='' type='set'>
    <patch xmlns='' node='collab-node' digest='b9e8241b3cc82c43af870641078ee03f'>
        @@ -4,8 +4,26 @@\n lo world\n+, have a nice day!\n

If the server succeeds to apply the patch to its shadow copy, it replies with a success result:

<iq id='234' from='' to='' type='result'>
    <success xmlns=''/>

Additionally the server MUST broadcast the patch to all other parties who are present on the node:

<iq id='345' from='' to='' type='set'>
    <patch xmlns='' node='collab-node'>
        @@ -4,8 +4,26 @@\n lo world\n+, have a nice day!\n

The parties MUST apply it to their text. If applying the patch fails, the server (or client) MUST reply with an iq stanza of type error. For instance if a patch was sent to the server and for some reason it was not possible to apply it to the shadow copy, the server would reply:

<iq id='234' from='' to='' type='error'>
    <error xmlns=''>
        Patch @@ -4,8 +4,26 @@\n lo world\n+, have a nice day!\n could not be applied.

In that case the client SHOULD sync again the current copy by sending an iq stanza of type get`requesting the shadow copy, see the `Initialization section above.

Finally, a patch element MAY have the digest attribute. In that case, the server SHOULD check the checksum and if there is a mismatch, reply with an error stanza if appropriate. Note that currently the checksum algorithm is not negotiated and is assumed to be MD5 hex digest.


In an environment where multiple nodes are edited in the same time (for instance in a context where the content has more than one collaboratively editable field) the client CAN send a notification specifying which particular node he is currently editing:

<message from='' to=''>
    <x xmlns=''>
        <item node='collab-node' action='focus' user=''/>

The server MUST propagate the message to all other users that are currently collaborating on the node:

<message from='' to=''>
    <x xmlns=''>
        <item node='collab-node' action='focus' user=''/>


At any point a party can request a save. This is done by sending a message whose item MUST indicate the node and its action must be set to save:

<message from='' to=''>
    <x xmlns=''>
        <item node='collab-node' action='save'></item>

It is up to the server component to enforce any security considerations on saving.


The session is terminated when the party sends an unavailable presence:

<presence from='' type='unavailable' />

Upon receipt, the server notifies any party that might still be editing the node:

<message from='' to=''>
    <x xmlns=''>
        <item action='user-left' node='collab-node' user=''/>


  • Most of this work was done using the 10% time available to Jarn AS employees for the development of open-source projects.
  • David Glick (davisagli) for dexterity support and general awesomeness.
  • jarn.xmpp.collaboration relies on the wonderful Diff-Match-Patch from Neil Fraser at Google. It is distributed under the Apache License 2.0.
Something went wrong with that request. Please try again.