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