<previous | top | next> | Pyro Manual |
The purpose of this chapter is to provide some insight in the Pyro's implementation. However please keep in mind that it is quite tedious for me to update this chapter with each Pyro release, so I want to stress the fact that the source code is probably the best place to look if you want to find out specific details about Pyro's implementation.
Nevertheless this chapter is a nice starting point to explore the different parts that make up Pyro.
XXX Unfinished
bin/*
- Command-line tools
__init__.py
- Pyro package initialization
configuration.py
- Configuration code
core.py
- Core code
naming.py
- Naming Server
protocol.py
- Protocol adapters
util.py
- Utility code
errors.py
- Exception definitions
The command-line tools are all in fact very small Python scripts. They contain a few Python statements that start the actual tools, which are part of the Pyro package:
Tool | Implemented in | Notes |
---|---|---|
nsc | Pyro.nsc | |
xnsc | Pyro.xnsc | |
pyroc | Pyro.pyroc | |
genguid | Pyro.util | entrypoint is genguid_scripthelper() . Module contains other
things as well. |
ns | Pyro.naming | entrypoint is main() . Module contains other things as well. |
Pyro is a Python package and as such is contained in the 'Pyro' directory.
This directory contains the different module files that make up the Pyro system.
One of them is the initialization file, __init__.py
. It sets Pyro.PYRO_VERSION
to the actual Pyro version, for instance '1.4'
. It also loads the
configuration settings for Pyro (Pyro.config.
* items).
This module contains the logic that deals with Pyro's configuration. There
is a Config
class and a ConfigReader
class. The Config
class is the container for all configuration items. The instance is available
as Pyro.config
(created in the package initializer, see above).
The configuration items are all attributes of this object. Config
uses the ConfigReader
to read Pyro's configuration file. It deals
with defaults and environment settings too.
This module contains all core logic of Pyro that is not tied to the network
protocol that is used. This means that you will not find any TCP/IP socket specific
code in the core module; the protocol
module
contains this. What the core module does contain is all stuff that realize the
core functions of Pyro:
ObjBase
Pyro_dyncall
)
and remote attribute access (remote_getattr
etc.)PyroURI
PyroURI
can be converted to and from a - human
readable - string.DynamicProxy
and DynamicProxyWithAttrs
__invokePYRO__
method that intercepts
method calls to pass them via the protocol adapter to the remote Pyro object.
Special care is taken to make proxy objects suitable for pickling so they
can be transported trough the Pyro protocol across the network.getProxyForURI
and getAttrProxyForURI
Daemon
TCPServer
and contains
the server end of a protocol adapter. The daemon passes incoming method calls
(via its handleRequest
method) to the protocol adapter that
sorts out what to do exactly. The connect
and disconnect
methods are used to keep track of server side Pyro objects. The Daemon's handleError
is used in case of a Pyro error, it processes the error and cleans things
up.initClient
and initServer
functions currently
only write some friendly strings to the log. However in the future they might
be needed to do more complex initialization.This module contains all logic that deals with object naming and locations. Pyro's Name Server is implemented here as well as various other things:
XXXXXXX
The idea behind this module is to make it fairly straightforward to switch the underlying protocol that Pyro uses. Currently only one implementation is available: the native PYRO protocol that sits on top of TCP/IP.
XXXXXXX
This module defines various utility functions and classes:
pickle
cPickle
or the
regular pickle
module)LoggerBase
SystemLogger
Pyro.util.Log
and this is Pyro's system logger that writes to Pyro's system logfile.UserLogger
ArgParser
getopt
function
in ANSI C. Pyro's command line tools use this. It can parse command line options
according to an option specification string. The getOpt
member
is used to read the results.int2binstr
binstr2int
int2binstr
).getBinaryGUID
bin2ascGUID
asc2binGUID
genguid_scripthelper
genguid
command line utility,
which prints a new GUID.supports_multithreading
This module defines Pyro.PyroError
and its derived exceptions.
PyroError
is the Pyro exception type that is used for problems
within Pyro. User code should not use it! Also, this module
defines the PyroExceptionCapsule
class, which is used to represent
any Python exception that has to be transported across the network, and raised
on the other side (by invoking raiseEx
on this object).