Commit 1f54a380 authored by Guido van Rossum's avatar Guido van Rossum

No longer use CLIENT_HOME, INSTANCE_HOME, or ZEO_CLIENT environment

variables.  Updated docstrings/comments.
parent db74d7a5
...@@ -122,16 +122,18 @@ from ZEO.ICache import ICache ...@@ -122,16 +122,18 @@ from ZEO.ICache import ICache
magic = 'ZEC1' magic = 'ZEC1'
headersize = 12 headersize = 12
MB = 1024**2
class ClientCache: class ClientCache:
__implements__ = ICache __implements__ = ICache
def __init__(self, storage='1', size=20000000, client=None, var=None): def __init__(self, storage='1', size=20*MB, client=None, var=None):
# Arguments: # Arguments:
# storage -- storage name (used in filenames and log messages) # storage -- storage name (used in filenames and log messages)
# size -- size limit in bytes of both files together # size -- size limit in bytes of both files together
# client -- if not None, use a persistent cache file and use this name # client -- if not None, use a persistent cache file and use this name
# var -- directory where to create persistent cache files # var -- directory where to create persistent cache files; default cwd
self._storage = storage self._storage = storage
self._limit = size / 2 self._limit = size / 2
...@@ -145,14 +147,7 @@ class ClientCache: ...@@ -145,14 +147,7 @@ class ClientCache:
if client is not None: if client is not None:
# Create a persistent cache # Create a persistent cache
# CLIENT_HOME and INSTANCE_HOME are builtins set by App.FindHomes
if var is None: if var is None:
try:
var = CLIENT_HOME
except:
try:
var = os.path.join(INSTANCE_HOME, 'var')
except:
var = os.getcwd() var = os.getcwd()
fmt = os.path.join(var, "c%s-%s-%%s.zec" % (storage, client)) fmt = os.path.join(var, "c%s-%s-%%s.zec" % (storage, client))
......
...@@ -141,16 +141,15 @@ class ClientStorage: ...@@ -141,16 +141,15 @@ class ClientStorage:
name -- The storage name, defaulting to ''. If this is false, name -- The storage name, defaulting to ''. If this is false,
str(addr) is used as the storage name. str(addr) is used as the storage name.
client -- The client name, defaulting to None. If this is client -- A name used to construct persistent cache filenames.
false, the environment value ZEO_CLIENT is used. If the Defaults to None, in which case the cache is not persistent.
effective value is true, the client cache is persistent.
See ClientCache for more info.
debug -- Ignored. This is present only for backwards debug -- Ignored. This is present only for backwards
compatibility with ZEO 1. compatibility with ZEO 1.
var -- The 'var' directory, defaulting to None, in which var -- When client is not None, this specifies the directory
the persistent cache files should be written. where the persistent cache files are created. It defaults
to None, in whichcase the current directory is used.
min_disconnect_poll -- The minimum delay in seconds between min_disconnect_poll -- The minimum delay in seconds between
attempts to connect to the server, in seconds. Defaults attempts to connect to the server, in seconds. Defaults
...@@ -249,7 +248,7 @@ class ClientStorage: ...@@ -249,7 +248,7 @@ class ClientStorage:
self._oid = '\0\0\0\0\0\0\0\0' self._oid = '\0\0\0\0\0\0\0\0'
# Decide whether to use non-temporary files # Decide whether to use non-temporary files
client = client or os.environ.get('ZEO_CLIENT') client = client
self._cache = self.ClientCacheClass(storage, cache_size, self._cache = self.ClientCacheClass(storage, cache_size,
client=client, var=var) client=client, var=var)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment