author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Tue, 28 Jun 2011 17:59:31 +0200 | |
changeset 7570 | 648bf83945a5 |
parent 4749 | 1560d51385f0 |
child 7813 | 89ab98c4aaab |
permissions | -rw-r--r-- |
4749
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
1 |
Working with a distributed client (using Pyro) |
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
2 |
============================================== |
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
3 |
|
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
4 |
In some circumstances, it is practical to split the repository and |
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
5 |
web-client parts of the application, for load-balancing reasons. Or |
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
6 |
one wants to access the repository from independant scripts to consult |
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
7 |
or update the database. |
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
8 |
|
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
9 |
For this to work, several steps have to be taken in order. |
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
10 |
|
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
11 |
You must first ensure that the apropriate software is installed and |
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
12 |
running (see ref:`setup`):: |
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
13 |
|
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
14 |
pyro-nsd -x -p 6969 |
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
15 |
|
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
16 |
Then you have to set appropriate options in your configuration. For |
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
17 |
instance:: |
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
18 |
|
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
19 |
pyro-server=yes |
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
20 |
pyro-ns-host=localhost:6969 |
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
21 |
|
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
22 |
pyro-instance-id=myinstancename |
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
23 |
|
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
24 |
Finally, the client (for instance in the case of a script) must |
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
25 |
connect specifically, as in the following example code: |
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
26 |
|
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
27 |
.. sourcecode:: python |
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
28 |
|
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
29 |
from cubicweb import dbapi |
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
30 |
|
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
31 |
def pyro_connect(instname, login, password, pyro_ns_host): |
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
32 |
cnx = dbapi.connect(instname, login, password, pyro_ns_host) |
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
33 |
cnx.load_appobjects() |
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
34 |
return cnx |
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
35 |
|
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
36 |
The 'cnx.load_appobjects()' line is optional. Without it you will get |
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
37 |
data through the connection roughly as you would from a DBAPI |
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
38 |
connection. With it, provided the cubicweb-client part is installed |
1560d51385f0
[book/admin/pyro] fix pyro options, give a small setup example
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
39 |
and accessible, you get the ORM goodies. |