Commit eb8fb48f authored by Andreas Jung's avatar Andreas Jung

using ZEO.hash

parent f2aff74a
...@@ -27,14 +27,7 @@ is set to 1 and the MAC immediately follows the length. ...@@ -27,14 +27,7 @@ is set to 1 and the MAC immediately follows the length.
import asyncore import asyncore
import errno import errno
try: import ZEO.hash
import hmac
except ImportError:
import _hmac as hmac
try:
from hashlib import sha1 as sha
except ImportError:
import sha
import socket import socket
import struct import struct
import threading import threading
...@@ -45,7 +38,7 @@ from ZODB.loglevels import TRACE ...@@ -45,7 +38,7 @@ from ZODB.loglevels import TRACE
from ZEO.zrpc.log import log, short_repr from ZEO.zrpc.log import log, short_repr
from ZEO.zrpc.error import DisconnectedError from ZEO.zrpc.error import DisconnectedError
import 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
# entries. We expect that EWOULDBLOCK == EAGAIN on most systems -- # entries. We expect that EWOULDBLOCK == EAGAIN on most systems --
...@@ -150,8 +143,8 @@ class SizedMessageAsyncConnection(asyncore.dispatcher): ...@@ -150,8 +143,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=sha) self.__hmac_send = hmac.HMAC(sesskey, digestmod=ZEO.hash)
self.__hmac_recv = hmac.HMAC(sesskey, digestmod=sha) self.__hmac_recv = hmac.HMAC(sesskey, digestmod=ZEO.hash)
if False: if False:
yield '' yield ''
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
$Id$""" $Id$"""
import sys
from ZODB.utils import oid_repr, readable_tid_repr from ZODB.utils import oid_repr, readable_tid_repr
# BBB: We moved the two transactions to the transaction package # BBB: We moved the two transactions to the transaction package
...@@ -34,22 +36,38 @@ _recon.__no_side_effects__ = True ...@@ -34,22 +36,38 @@ _recon.__no_side_effects__ = True
class POSError(StandardError): class POSError(StandardError):
"""Persistent object system error.""" """Persistent object system error."""
if sys.version_info[:2] == (2, 6):
# The 'message' attribute was deprecated for BaseException with
# Python 2.6; here we create descriptor properties to continue using it
def __set_message(self, v):
self.__dict__['message'] = v
def __get_message(self):
return self.__dict__['message']
def __del_message(self):
del self.__dict__['message']
message = property(__get_message, __set_message, __del_message)
if sys.version_info[:2] >= (2, 5):
def __reduce__(self): def __reduce__(self):
# Cope extra data from internal structures # Copy extra data from internal structures
state = self.__dict__.copy() state = self.__dict__.copy()
if sys.version_info[:2] == (2, 5):
state['message'] = self.message state['message'] = self.message
state['args'] = self.args state['args'] = self.args
return (_recon, (self.__class__, state)) return (_recon, (self.__class__, state))
class POSKeyError(KeyError, POSError): class POSKeyError(POSError, KeyError):
"""Key not found in database.""" """Key not found in database."""
def __str__(self): def __str__(self):
return oid_repr(self.args[0]) return oid_repr(self.args[0])
class ConflictError(TransactionError): class ConflictError(POSError, TransactionError):
"""Two transactions tried to modify the same object at once. """Two transactions tried to modify the same object at once.
This transaction should be resubmitted. This transaction should be resubmitted.
...@@ -213,7 +231,7 @@ class BTreesConflictError(ConflictError): ...@@ -213,7 +231,7 @@ class BTreesConflictError(ConflictError):
return "BTrees conflict error at %d/%d/%d: %s" % ( return "BTrees conflict error at %d/%d/%d: %s" % (
self.p1, self.p2, self.p3, self.msgs[self.reason]) self.p1, self.p2, self.p3, self.msgs[self.reason])
class DanglingReferenceError(TransactionError): class DanglingReferenceError(POSError, TransactionError):
"""An object has a persistent reference to a missing object. """An object has a persistent reference to a missing object.
If an object is stored and it has a reference to another object If an object is stored and it has a reference to another object
......
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