doc/book/en/admin/pyro.rst
branchstable
changeset 4749 1560d51385f0
child 7813 89ab98c4aaab
equal deleted inserted replaced
4748:135329e51713 4749:1560d51385f0
       
     1 Working with a distributed client (using Pyro)
       
     2 ==============================================
       
     3 
       
     4 In some circumstances, it is practical to split the repository and
       
     5 web-client parts of the application, for load-balancing reasons. Or
       
     6 one wants to access the repository from independant scripts to consult
       
     7 or update the database.
       
     8 
       
     9 For this to work, several steps have to be taken in order.
       
    10 
       
    11 You must first ensure that the apropriate software is installed and
       
    12 running (see ref:`setup`)::
       
    13 
       
    14   pyro-nsd -x -p 6969
       
    15 
       
    16 Then you have to set appropriate options in your configuration. For
       
    17 instance::
       
    18 
       
    19   pyro-server=yes
       
    20   pyro-ns-host=localhost:6969
       
    21 
       
    22   pyro-instance-id=myinstancename
       
    23 
       
    24 Finally, the client (for instance in the case of a script) must
       
    25 connect specifically, as in the following example code:
       
    26 
       
    27 .. sourcecode:: python
       
    28 
       
    29     from cubicweb import dbapi
       
    30 
       
    31     def pyro_connect(instname, login, password, pyro_ns_host):
       
    32         cnx = dbapi.connect(instname, login, password, pyro_ns_host)
       
    33         cnx.load_appobjects()
       
    34         return cnx
       
    35 
       
    36 The 'cnx.load_appobjects()' line is optional. Without it you will get
       
    37 data through the connection roughly as you would from a DBAPI
       
    38 connection. With it, provided the cubicweb-client part is installed
       
    39 and accessible, you get the ORM goodies.