doc/book/en/admin/pyro.rst
author Julien Jehannet <julien.jehannet@logilab.fr>
Thu, 16 Jun 2011 12:31:27 +0200
branchstable
changeset 7529 2fdc310be7cd
parent 4749 1560d51385f0
child 7813 89ab98c4aaab
permissions -rw-r--r--
[book] add autoload section from code and fix sphinx warnings * drop misleading faq entry since clear explanation can be found in internationalization chapter * use autodata sphinx directive instead of raw text * fill empty chapter with autodoc: - devweb/httpcaching.rst - devweb/resource.rst - devweb/views/idownloadable.rst - devweb/views/wdoc.rst * use shebang in excerpt to denote shell code * fix some bad indented docstrings in javascript files

Working with a distributed client (using Pyro)
==============================================

In some circumstances, it is practical to split the repository and
web-client parts of the application, for load-balancing reasons. Or
one wants to access the repository from independant scripts to consult
or update the database.

For this to work, several steps have to be taken in order.

You must first ensure that the apropriate software is installed and
running (see ref:`setup`)::

  pyro-nsd -x -p 6969

Then you have to set appropriate options in your configuration. For
instance::

  pyro-server=yes
  pyro-ns-host=localhost:6969

  pyro-instance-id=myinstancename

Finally, the client (for instance in the case of a script) must
connect specifically, as in the following example code:

.. sourcecode:: python

    from cubicweb import dbapi

    def pyro_connect(instname, login, password, pyro_ns_host):
        cnx = dbapi.connect(instname, login, password, pyro_ns_host)
        cnx.load_appobjects()
        return cnx

The 'cnx.load_appobjects()' line is optional. Without it you will get
data through the connection roughly as you would from a DBAPI
connection. With it, provided the cubicweb-client part is installed
and accessible, you get the ORM goodies.