Skip to content

Commit

Permalink
First stab at relative imports. Some success, but much pain, then ZCo…
Browse files Browse the repository at this point in the history
…nfig
  • Loading branch information
Jim Fulton committed Aug 1, 2016
1 parent 934650e commit 981f890
Show file tree
Hide file tree
Showing 58 changed files with 511 additions and 508 deletions.
5 changes: 3 additions & 2 deletions buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ parts =
test
scripts
versions = versions
name = ZEO

[versions]


[test]
recipe = zc.recipe.testrunner
eggs =
ZEO [test]
${buildout:name} [test]
initialization =
import os, tempfile
try: os.mkdir('tmp')
Expand All @@ -22,5 +23,5 @@ defaults = ['--all']
[scripts]
recipe = zc.recipe.egg
eggs =
ZEO [test]
${buildout:name} [test]
interpreter = py
19 changes: 9 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################

name = 'ZEO4'
version = '4.2.1'

from setuptools import setup, find_packages
Expand Down Expand Up @@ -72,7 +72,6 @@ def alltests():
import logging
import pkg_resources
import unittest
import ZEO.ClientStorage

class NullHandler(logging.Handler):
level = 50
Expand All @@ -84,7 +83,7 @@ def emit(self, record):

suite = unittest.TestSuite()
base = pkg_resources.working_set.find(
pkg_resources.Requirement.parse('ZEO')).location
pkg_resources.Requirement.parse(name)).location
for dirpath, dirnames, filenames in os.walk(base):
if os.path.basename(dirpath) == 'tests':
for filename in filenames:
Expand All @@ -103,7 +102,7 @@ def emit(self, record):
+ '\n' +
open('CHANGES.rst').read()
)
setup(name="ZEO",
setup(name=name,
version=version,
description = long_description.split('\n', 2)[1],
long_description = long_description,
Expand Down Expand Up @@ -131,11 +130,11 @@ def emit(self, record):
zip_safe = False,
entry_points = """
[console_scripts]
zeopack = ZEO.scripts.zeopack:main
runzeo = ZEO.runzeo:main
zeopasswd = ZEO.zeopasswd:main
zeoctl = ZEO.zeoctl:main
zeo-nagios = ZEO.nagios:main
""",
zeopack = {name}.scripts.zeopack:main
runzeo = {name}.runzeo:main
zeopasswd = {name}.zeopasswd:main
zeoctl = {name}.zeoctl:main
zeo-nagios = {name}.nagios:main
""".format(name=name),
include_package_data = True,
)
23 changes: 12 additions & 11 deletions src/ZEO/ClientStorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,25 @@
import weakref
from binascii import hexlify

from ZODB import POSException
from ZODB import utils
import zc.lockfile
import ZEO.interfaces
import ZODB
import ZODB.BaseStorage
import ZODB.interfaces
import ZODB.event
import zope.interface
import six
from persistent.TimeStamp import TimeStamp
from ZEO._compat import Pickler, Unpickler, get_ident, PY3
from ZEO.auth import get_module
from ZEO.cache import ClientCache
from ZEO.Exceptions import ClientStorageError, ClientDisconnected, AuthError
from ZEO import ServerStub
from ZEO.TransactionBuffer import TransactionBuffer
from ZEO.zrpc.client import ConnectionManager
from ZODB import POSException
from ZODB import utils

from . import interfaces
from . import ServerStub
from ._compat import Pickler, Unpickler, get_ident, PY3
from .auth import get_module
from .cache import ClientCache
from .Exceptions import ClientStorageError, ClientDisconnected, AuthError
from .TransactionBuffer import TransactionBuffer
from .zrpc.client import ConnectionManager

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -1366,7 +1367,7 @@ def verify_cache(self, server):
self._cache.setLastTid(server_tid)


ZODB.event.notify(ZEO.interfaces.StaleCache(self))
ZODB.event.notify(interfaces.StaleCache(self))

# From this point on, we do not have complete information about
# the missed transactions. The reason is that cache
Expand Down
34 changes: 17 additions & 17 deletions src/ZEO/StorageServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,27 @@
import time
import transaction
import warnings
import ZEO.zrpc.error
from .zrpc.error import DisconnectedError
from ZODB.ConflictResolution import ResolvedSerial
from ZODB.loglevels import BLATHER
from ZODB.POSException import StorageError, StorageTransactionError
from ZODB.POSException import TransactionError, ReadOnlyError, ConflictError
from ZODB.serialize import referencesf
from ZODB.utils import oid_repr, p64, u64, z64
import ZODB.blob
import ZODB.event
import ZODB.serialize
import ZODB.TimeStamp
import zope.interface
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 ZODB.ConflictResolution import ResolvedSerial
from ZODB.loglevels import BLATHER
from ZODB.POSException import StorageError, StorageTransactionError
from ZODB.POSException import TransactionError, ReadOnlyError, ConflictError
from ZODB.serialize import referencesf
from ZODB.utils import oid_repr, p64, u64, z64
from ._compat import Pickler, Unpickler, PY3, BytesIO
from .Exceptions import AuthError
from .monitor import StorageStats, StatsServer
from .zrpc.connection import ManagedServerConnection, Delay, MTDelay, Result
from .zrpc.server import Dispatcher

logger = logging.getLogger('ZEO.StorageServer')
logger = logging.getLogger(__file__)

def log(message, level=logging.INFO, label='', exc_info=False):
"""Internal helper to log a message."""
Expand Down Expand Up @@ -790,7 +790,7 @@ class StorageServer:

# Classes we instantiate. A subclass might override.

DispatcherClass = ZEO.zrpc.server.Dispatcher
DispatcherClass = Dispatcher
ZEOStorageClass = ZEOStorage
ManagedServerConnectionClass = ManagedServerConnection

Expand Down Expand Up @@ -947,7 +947,7 @@ def _setup_invq(self, name, storage):

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__

Expand Down Expand Up @@ -1049,7 +1049,7 @@ def _invalidateCache(self, storage_id):
try:
p.connection.should_close()
p.connection.trigger.pull_trigger()
except ZEO.zrpc.error.DisconnectedError:
except DisconnectedError:
pass


Expand Down Expand Up @@ -1111,7 +1111,7 @@ def invalidate(self, conn, storage_id, tid, invalidated=(), info=None):
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):
Expand Down
2 changes: 1 addition & 1 deletion src/ZEO/TransactionBuffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import os
import tempfile
import ZODB.blob
from ZEO._compat import Pickler, Unpickler
from ._compat import Pickler, Unpickler

class TransactionBuffer:

Expand Down
18 changes: 7 additions & 11 deletions src/ZEO/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,11 @@
"""ZEO -- Zope Enterprise Objects.
See the file README.txt in this directory for an overview.
ZEO is now part of ZODB; ZODB's home on the web is
http://wiki.zope.org/ZODB
"""

def client(*args, **kw):
import ZEO.ClientStorage
return ZEO.ClientStorage.ClientStorage(*args, **kw)
from .ClientStorage import ClientStorage
return ClientStorage(*args, **kw)

def DB(*args, **kw):
import ZODB
Expand Down Expand Up @@ -71,17 +66,18 @@ def server(path=None, blob_dir=None, storage_conf=None, zeo_conf=None,
randomly.
"""
import os, ZEO.tests.forker
import os
from .tests import forker
if storage_conf is None and path is None:
storage_conf = '<mappingstorage>\n</mappingstorage>'
if port is None and zeo_conf is None:
port = ZEO.tests.forker.get_port()
port = forker.get_port()

addr, admin, pid, config = ZEO.tests.forker.start_zeo_server(
addr, admin, pid, config = forker.start_zeo_server(
storage_conf, zeo_conf, port, keep=True, path=path,
blob_dir=blob_dir, suicide=False)
os.remove(config)
def stop_server():
ZEO.tests.forker.shutdown_zeo_server(admin)
forker.shutdown_zeo_server(admin)
os.waitpid(pid, 0)
return addr, stop_server
9 changes: 5 additions & 4 deletions src/ZEO/auth/auth_digest.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@
import struct
import time

from ZEO.auth.base import Database, Client
from ZEO.StorageServer import ZEOStorage
from ZEO.Exceptions import AuthError
from ZEO.hash import sha1
from ..StorageServer import ZEOStorage
from ..Exceptions import AuthError
from ..hash import sha1

from .base import Database, Client

def get_random_bytes(n=8):
try:
Expand Down
2 changes: 1 addition & 1 deletion src/ZEO/auth/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion src/ZEO/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import six
from ._compat import PYPY

logger = logging.getLogger("ZEO.cache")
logger = logging.getLogger(__name__)

# A disk-based cache for ZEO clients.
#
Expand Down
5 changes: 2 additions & 3 deletions src/ZEO/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#
##############################################################################
"""Monitor behavior of ZEO server and record statistics.
$Id$
"""
from __future__ import print_function
from __future__ import print_function
Expand All @@ -37,6 +35,8 @@
import time
import logging

logger = logging.getLogger(__name__)

zeo_version = 'unknown'
try:
import pkg_resources
Expand Down Expand Up @@ -159,7 +159,6 @@ def __init__(self, addr, stats):
else:
self.create_socket(socket.AF_UNIX, socket.SOCK_STREAM)
self.set_reuse_addr()
logger = logging.getLogger('ZEO.monitor')
logger.info("listening on %s", repr(self.addr))
self.bind(self.addr)
self.listen(5)
Expand Down
7 changes: 3 additions & 4 deletions src/ZEO/runzeo.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@
import logging

import ZConfig.datatypes
import ZEO
from zdaemon.zdoptions import ZDOptions

logger = logging.getLogger('ZEO.runzeo')
logger = logging.getLogger(__name__)
_pid = str(os.getpid())

def log(msg, level=logging.INFO, exc_info=False):
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -344,7 +343,7 @@ def remove_pidfile(self):


def create_server(storages, options):
from ZEO.StorageServer import StorageServer
from .StorageServer import StorageServer
return StorageServer(
options.address,
storages,
Expand Down
8 changes: 3 additions & 5 deletions src/ZEO/scripts/cache_simul.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import struct
import re
import sys
import ZEO.cache
from .. import cache
import argparse

from ZODB.utils import z64
Expand Down Expand Up @@ -270,7 +270,7 @@ def __init__(self, key, end_tid, offset):
self.end_tid = end_tid
self.offset = offset

from ZEO.cache import ZEC_HEADER_SIZE
from ..cache import ZEC_HEADER_SIZE

class CircularCacheSimulation(Simulation):
"""Simulate the ZEO 3.0 cache."""
Expand All @@ -285,8 +285,6 @@ class CircularCacheSimulation(Simulation):
evicts = 0

def __init__(self, cachelimit, rearrange):
from ZEO import cache

Simulation.__init__(self, cachelimit, rearrange)
self.total_evicts = 0 # number of cache evictions

Expand All @@ -309,7 +307,7 @@ def __init__(self, cachelimit, rearrange):

# The number of overhead bytes needed to store an object pickle
# on disk (all bytes beyond those needed for the object pickle).
self.overhead = ZEO.cache.allocated_record_overhead
self.overhead = cache.allocated_record_overhead

# save evictions so we can replay them, if necessary
self.evicted = {}
Expand Down
2 changes: 1 addition & 1 deletion src/ZEO/scripts/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_suite():
(re.compile('usage: Usage: '), 'Usage: '), # Py 2.4
(re.compile('options:'), 'Options:'), # Py 2.4
]),
globs={'print_function': print_function},
globs=dict(print_function=print_function, __name__=__name__),
),
))

2 changes: 1 addition & 1 deletion src/ZEO/scripts/timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from ZODB.Transaction import Transaction
from ZODB.tests.MinPO import MinPO
from ZODB.tests.StorageTestBase import zodb_pickle
from ZEO.ClientStorage import ClientStorage
from ...ClientStorage import ClientStorage

ZERO = '\0'*8

Expand Down
Loading

0 comments on commit 981f890

Please sign in to comment.