Setting up Synchronization

  Installing packages

    First install zope and all products you might need (CPS...)
    Then install products ERP5Type, CMFActivity, ERP5SyncML.
    available with the nexedi cvs.
    And also CMFWiki, psyco, available from zope and python. You will
    also need xml for python.

    We use for the synchronization a tool wich is able to generate
    xupdate xml. Xupdate xml is described on this website ::
  
      http://www.xmldb.org/xupdate/

    We have made on own tool to generate xupdate xml, so you need
    to install the erp5diff software.
    

    If you want the synchronization working with CPS, you will need
    need the ERP5CPS products, available on the nexedi cvs.

  Install Site instances

    If you want to do synchronization, you should have at least two Site
    instances (it can actually be either ERP5 Site or CPS Site). One of them
    has to be a master and all other have to be clients.

    Any modification made on any Site will be sent to the master, and the master
    send back each modification to each client. Like this, all Sites (master and 
    clients) are informed about modifications.

    Let's say we have one zope running on our local box. We will create for
    example two CPS Sites, the fist one wich will be the master with the id 
    'cps', and the second one wich will be the client with the id 'cps_client'.

    If you want to make sure that your box is installed correctly, you should
    go on one object of your site and then addto the url the method 'asXML' like
    this ::

      http://localhost:9673/cps/workspaces/members/seb/gggggggggggggg/asXML

    If everything is fine, you should have no errors and you should see the
    xml corresponding to your object.

  Installing the synchronization tool

    Go to the zope management interface and then add to all your sites (master
    and clients) an ERP5SyncML Tool.

  Configuration for synchronization by http

    The particular thing with the synchronization by http is that we need
    to use active objects. Active Object allows to differ a method call.
    We need it in order to differ html request, active object allows to
    send all html request to a queue.

    Don't worry, it is really simple to use. First, you have to add inside
    all your sites (master and clients) a 'CMFActivity Tool'. There is nothing 
    to configure. Then, only thing needed is to modify the script 
    'zope_tic_loop' located inside your CMFActivity product. Since it requires
    many changes you can take my following example and then you have to modify 
    the user name, the user password, the ip where your zope is running and 
    the id of your sites. 

    For example, my script looks like this ::

      #!/bin/bash
      while true; do
      # Site 1 (the master one)
      wget -O /tmp/zope_distribute.out http://seb:password@localhost:9673/cps/portal_activities/distribute?node_count:int=1
      wget -O /tmp/zope_tic.out http://seb:password@localhost:9673/cps/portal_activities/tic?processing_node:int=1
      # Site 2 (the client one)
      wget -O /tmp/zope_distribute.out http://seb:password@localhost:9673/cps_client/portal_activities/distribute?node_count:int=1
      wget -O /tmp/zope_tic.out http://seb:password@localhost:9673/cps_client/portal_activities/tic?processing_node:int=1
      sleep 5
      done

    This allows to run all html requests each time there is a new one. It is
    a nice idea to run the script like this ::
    
      nohup ./zope_tic_loop &

    The last thing to do is to configure you synchronization tool inside
    the zope management interface. You have in this tool many tabs. The 
    'publication' tab is used on the server and the 'subscription' tab 
    is used on all clients. A publication is a setting for something we
    want to share with others. So on the master we have to specify as
    many publication as the number of folders we want to share. A subscription
    is a setting for something we want to synchronize from a master, so on each
    client we have to specify as many subscriptions as the number of folders
    we want to synchronize with the master.

    I do have on my server side the following publication ::

      id : Repository
      Publication Url : http://localhost:9673/cps
      Destination Path : /cps/portal_repository
      Query : objectValues (it will be completed automatically)
      XML Mapping : asXML
      GPG key name :    (it can stay empty)

    I do have on my client side the following subscription ::

      id : Repository
      Publication Url : http://localhost:9673/cps
      Subscription Url : http://localhost:9673/cps_client/Repository 
      Destination Path : /cps_client/portal_repository
      Query : objectValues (it will be completed automatically)
      XML Mapping : asXML
      GPG key name :    (it can stay empty)

  CPS Synchronization

    This is just a note for people who wants to synchronize some CPS Sites, you have to
    synchronize theses directories ::

      /cps_site/portal_repository
      /cps_site/workspaces
      /cps_site/sections

  Starting synchronization

    The synchronization starts only from a client, so you should go on one of the client
    instance. Then you have to go on the portal_synchronizations and select one of the
    subscriptions and hit 'Sync'.

  Configuration for synchronization by email

    Actually you need to add a 'CMFMailin Tool', there is nothing to configure.
    Then you have to make sure you get the right mail_received.py. The
    mail_received script has to be modified in order to use SubSync or PubSync.
    SubSync is used if we are on the client side, PubSync is used if we are on
    the master side.

    You can find the mail_received inside the ERP5SyncML/skins/ folder. You can
    just make a copy inside your ZODB. For that, you should go to your cps site,
    inside portal_skins and then select the "custom" folder. Then add a script
    python called "mail_received". Then set the parameter list to "theMail", and
    then paste the content of ERP5CPS/skins/mail_received.py .


    Inside the synchronization tool (cps_site/portal_synchrozations), 
    the publication should looks like this ::

      id : Repository
      Publication Url : mailto:cps_server@localhost
      Destination Path : /cps/portal_repository
      Query : objectValues (it will be completed automatically)
      XML Mapping : asXML

    Inside the synchronization tool, the subscription should looks like this ::

      id : Repository
      Publication Url : mailto:cps_server@localhost
      Subscription Url : mailto:cps_client@localhost
      Destination Path : /cps_client/portal_repository
      Query : objectValues (it will be completed automatically)
      XML Mapping : asXML

    If you want to synchronize, you should have at least 2 instances of cmf sites. One of
    them should act as a server, and all over as client. On the server you have to setup
    publications and on client you have to setup subscriptions.

  Configure your mail server (email synchronization)

    You should set some aliases so that your mail server will directly sends
    mail to zope, for example in /etc/aliases :

    seb_syncml: "|/home/seb/erp5/CMFMailIn/sendMailToZope.py http://seb:password@localhost:9673/nexedi.org/portal_mailin/"

    This is really important that the master and all clients can send mails each others.
    On each box I set a local postfix server and I also use fetchmail every 20 secondes in
    order to do a synchronization not too long. A nice way to do is to create a specific
    user, for example I do have on my box an user 'seb_syncml'. This user have on his 
    home directory an file .fetchmailrc like this ::

      set daemon 20
      set syslog
      defaults user "seb_syncml"
              pass "password"
              smtpname "seb_syncml@localhost"
        fetchall
      poll localhost proto imap port 11143

