Pyro4.naming — Pyro name server

Name Server and helper functions.

Pyro4.naming.locateNS(host=None, port=None, broadcast=True, hmac_key=None)

Get a proxy for a name server somewhere in the network.

Pyro4.naming.resolve(uri, hmac_key=None)

Resolve a ‘magic’ uri (PYRONAME, PYROMETA) into the direct PYRO uri. It finds a name server, and use that to resolve a PYRONAME uri into the direct PYRO uri pointing to the named object. If uri is already a PYRO uri, it is returned unmodified. You can consider this a shortcut function so that you don’t have to locate and use a name server proxy yourself. Note: if you need to resolve more than a few names, consider using the name server directly instead of repeatedly calling this function, to avoid the name server lookup overhead from each call.

Pyro4.naming.startNS(host=None, port=None, enableBroadcast=True, bchost=None, bcport=None, unixsocket=None, nathost=None, natport=None, storage=None, hmac=None)

utility fuction to quickly get a Name server daemon to be used in your own event loops. Returns (nameserverUri, nameserverDaemon, broadcastServer).

Pyro4.naming.startNSloop(host=None, port=None, enableBroadcast=True, bchost=None, bcport=None, unixsocket=None, nathost=None, natport=None, storage=None, hmac=None)

utility function that starts a new Name server and enters its requestloop.

Pyro4.naming.type_meta(class_or_object, prefix='class:')

extracts type metadata from the given class or object, can be used as Name server metadata.

class Pyro4.naming.NameServer(storageProvider=None)

Pyro name server. Provides a simple flat name space to map logical object names to Pyro URIs. Default storage is done in an in-memory dictionary. You can provide custom storage types.

count()

Returns the number of name registrations.

list(prefix=None, regex=None, metadata_all=None, metadata_any=None, return_metadata=False)

Retrieve the registered items as a dictionary name-to-URI. The URIs in the resulting dict are strings, not URI objects. You can filter by prefix or by regex or by metadata subset (separately)

lookup(name, return_metadata=False)

Lookup the given name, returns an URI if found. Returns tuple (uri, metadata) if return_metadata is True.

ping()

A simple test method to check if the name server is running correctly.

register(name, uri, safe=False, metadata=None)

Register a name with an URI. If safe is true, name cannot be registered twice. The uri can be a string or an URI object. Metadata must be None, or a collection of strings.

remove(name=None, prefix=None, regex=None)

Remove a registration. returns the number of items removed.

set_metadata(name, metadata)

update the metadata for an existing registration

Name Server persistent storage implementations.

class Pyro4.naming_storage.DbmStorage(dbmfile)

Storage implementation that uses a persistent dbm file. Because dbm only supports strings as key/value, we encode/decode them in utf-8. Dbm files cannot be accessed concurrently, so a strict concurrency model is used where only one operation is processed at the same time (this is very slow when compared to the in-memory storage) DbmStorage does NOT support storing metadata! It only accepts empty metadata, and always returns empty metadata.

clear() None.  Remove all items from D.
class Pyro4.naming_storage.SqlStorage(dbfile)

Sqlite-based storage. It is just a single (name,uri) table for the names and another table for the metadata. Sqlite db connection objects aren’t thread-safe, so a new connection is created in every method.

clear() None.  Remove all items from D.