Commit f71114f0 authored by Jim Fulton's avatar Jim Fulton

Use relative imports in server code so it can be reused in ZEO5 tests

parent 4aaf4b62
......@@ -30,7 +30,7 @@ import threading
import time
import transaction
import warnings
import ZEO.zrpc.error
from .zrpc.error import DisconnectedError
import ZODB.blob
import ZODB.event
import ZODB.serialize
......@@ -40,9 +40,9 @@ import six
from ZEO._compat import Pickler, Unpickler, PY3, BytesIO
from ZEO.Exceptions import AuthError
from ZEO.monitor import StorageStats, StatsServer
from ZEO.zrpc.connection import ManagedServerConnection, Delay, MTDelay, Result
from ZEO.zrpc.server import Dispatcher
from .monitor import StorageStats, StatsServer
from .zrpc.connection import ManagedServerConnection, Delay, MTDelay, Result
from .zrpc.server import Dispatcher
from ZODB.ConflictResolution import ResolvedSerial
from ZODB.loglevels import BLATHER
from ZODB.POSException import StorageError, StorageTransactionError
......@@ -790,7 +790,7 @@ class StorageServer:
# Classes we instantiate. A subclass might override.
DispatcherClass = ZEO.zrpc.server.Dispatcher
from .zrpc.server import Dispatcher as DispatcherClass
ZEOStorageClass = ZEOStorage
ManagedServerConnectionClass = ManagedServerConnection
......@@ -947,7 +947,7 @@ class StorageServer:
def _setup_auth(self, protocol):
# Can't be done in global scope, because of cyclic references
from ZEO.auth import get_module
from .auth import get_module
name = self.__class__.__name__
......@@ -1049,7 +1049,7 @@ class StorageServer:
try:
p.connection.should_close()
p.connection.trigger.pull_trigger()
except ZEO.zrpc.error.DisconnectedError:
except DisconnectedError:
pass
......@@ -1111,7 +1111,7 @@ class StorageServer:
p.client.invalidateTransaction(tid, invalidated)
elif info is not None:
p.client.info(info)
except ZEO.zrpc.error.DisconnectedError:
except DisconnectedError:
pass
def get_invalidations(self, storage_id, tid):
......
......@@ -40,10 +40,10 @@ import random
import struct
import time
from ZEO.auth.base import Database, Client
from ZEO.StorageServer import ZEOStorage
from .base import Database, Client
from ..StorageServer import ZEOStorage
from ZEO.Exceptions import AuthError
from ZEO.hash import sha1
from ..hash import sha1
def get_random_bytes(n=8):
try:
......
......@@ -20,7 +20,7 @@ from __future__ import print_function
from __future__ import print_function
import os
from ZEO.hash import sha1
from ..hash import sha1
class Client:
# Subclass should override to list the names of methods that
......
......@@ -12,8 +12,6 @@
#
##############################################################################
"""Monitor behavior of ZEO server and record statistics.
$Id$
"""
from __future__ import print_function
from __future__ import print_function
......
......@@ -44,7 +44,6 @@ import socket
import logging
import ZConfig.datatypes
import ZEO
from zdaemon.zdoptions import ZDOptions
logger = logging.getLogger('ZEO.runzeo')
......@@ -123,7 +122,7 @@ class ZEOOptions(ZDOptions, ZEOOptionsMixin):
__doc__ = __doc__
logsectionname = "eventlog"
schemadir = os.path.dirname(ZEO.__file__)
schemadir = os.path.dirname(__file__)
def __init__(self):
ZDOptions.__init__(self)
......@@ -344,7 +343,7 @@ class ZEOServer:
def create_server(storages, options):
from ZEO.StorageServer import StorageServer
from .StorageServer import StorageServer
return StorageServer(
options.address,
storages,
......
......@@ -19,12 +19,12 @@ import socket
import sys
import threading
import time
import ZEO.zrpc.trigger
from . import trigger
from ZEO.zrpc.connection import ManagedClientConnection
from ZEO.zrpc.log import log
from ZEO.zrpc.error import DisconnectedError
from .connection import ManagedClientConnection
from .log import log
from .error import DisconnectedError
from ZODB.POSException import ReadOnlyError
from ZODB.loglevels import BLATHER
......@@ -163,7 +163,7 @@ class ConnectionManager(object):
def _start_asyncore_loop(self):
self.map = {}
self.trigger = ZEO.zrpc.trigger.trigger(self.map)
self.trigger = trigger.trigger(self.map)
self.loop_thread = threading.Thread(
name="%s zeo client networking thread" % self.client.__name__,
target=client_loop, args=(self.map,))
......
......@@ -17,13 +17,12 @@ import json
import sys
import threading
import logging
import ZEO.zrpc.marshal
from . import marshal
from . import trigger
import ZEO.zrpc.trigger
from ZEO.zrpc import smac
from ZEO.zrpc.error import ZRPCError, DisconnectedError
from ZEO.zrpc.log import short_repr, log
from . import smac
from .error import ZRPCError, DisconnectedError
from .log import short_repr, log
from ZODB.loglevels import BLATHER, TRACE
import ZODB.POSException
......@@ -290,9 +289,9 @@ class Connection(smac.SizedMessageAsyncConnection, object):
# our peer.
def __init__(self, sock, addr, obj, tag, map=None):
self.obj = None
self.decode = ZEO.zrpc.marshal.decode
self.encode = ZEO.zrpc.marshal.encode
self.fast_encode = ZEO.zrpc.marshal.fast_encode
self.decode = marshal.decode
self.encode = marshal.encode
self.fast_encode = marshal.fast_encode
self.closed = False
self.peer_protocol_version = None # set in recv_handshake()
......@@ -613,9 +612,9 @@ class ManagedServerConnection(Connection):
map = {}
Connection.__init__(self, sock, addr, obj, b'S', map=map)
self.decode = ZEO.zrpc.marshal.server_decode
self.decode = marshal.server_decode
self.trigger = ZEO.zrpc.trigger.trigger(map)
self.trigger = trigger.trigger(map)
self.call_from_thread = self.trigger.pull_trigger
t = threading.Thread(target=server_loop, args=(map,))
......
......@@ -14,8 +14,8 @@
import logging
from ZEO._compat import Unpickler, Pickler, BytesIO, PY3, PYPY
from ZEO.zrpc.error import ZRPCError
from ZEO.zrpc.log import log, short_repr
from .error import ZRPCError
from .log import log, short_repr
def encode(*args): # args: (msgid, flags, name, args)
# (We used to have a global pickler, but that's not thread-safe. :-( )
......
......@@ -31,9 +31,9 @@ else:
s.close()
del s
from ZEO.zrpc.connection import Connection
from ZEO.zrpc.log import log
import ZEO.zrpc.log
from .connection import Connection
from .log import log
from .log import logger
import logging
# Export the main asyncore loop
......@@ -119,6 +119,6 @@ class Dispatcher(asyncore.dispatcher):
except:
if sock.fileno() in asyncore.socket_map:
del asyncore.socket_map[sock.fileno()]
ZEO.zrpc.log.logger.exception("Error in handle_accept")
logger.exception("Error in handle_accept")
else:
log("connect from %s: %s" % (repr(addr), c))
......@@ -36,9 +36,9 @@ import socket
import struct
import threading
from ZEO.zrpc.log import log
from ZEO.zrpc.error import DisconnectedError
import ZEO.hash
from .log import log
from .error import DisconnectedError
from .. import hash as ZEO_hash
# Use the dictionary to make sure we get the minimum number of errno
......@@ -144,8 +144,8 @@ class SizedMessageAsyncConnection(asyncore.dispatcher):
# and thus iterator, because it contains a yield statement.
def hack():
self.__hmac_send = hmac.HMAC(sesskey, digestmod=ZEO.hash)
self.__hmac_recv = hmac.HMAC(sesskey, digestmod=ZEO.hash)
self.__hmac_send = hmac.HMAC(sesskey, digestmod=ZEO_hash)
self.__hmac_recv = hmac.HMAC(sesskey, digestmod=ZEO_hash)
if False:
yield b''
......
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