[Zodb-checkins] SVN: ZODB/trunk/src/Z using ZEO.hash
Andreas Jung
andreas at andreas-jung.com
Mon Mar 30 16:44:57 EDT 2009
Log message for revision 98631:
using ZEO.hash
Changed:
U ZODB/trunk/src/ZEO/zrpc/smac.py
U ZODB/trunk/src/ZODB/POSException.py
-=-
Modified: ZODB/trunk/src/ZEO/zrpc/smac.py
===================================================================
--- ZODB/trunk/src/ZEO/zrpc/smac.py 2009-03-30 20:41:26 UTC (rev 98630)
+++ ZODB/trunk/src/ZEO/zrpc/smac.py 2009-03-30 20:44:57 UTC (rev 98631)
@@ -27,14 +27,7 @@
import asyncore
import errno
-try:
- import hmac
-except ImportError:
- import _hmac as hmac
-try:
- from hashlib import sha1 as sha
-except ImportError:
- import sha
+import ZEO.hash
import socket
import struct
import threading
@@ -45,8 +38,8 @@
from ZEO.zrpc.log import log, short_repr
from ZEO.zrpc.error import DisconnectedError
+import ZEO.hash
-
# Use the dictionary to make sure we get the minimum number of errno
# entries. We expect that EWOULDBLOCK == EAGAIN on most systems --
# or that only one is actually used.
@@ -150,8 +143,8 @@
# and thus iterator, because it contains a yield statement.
def hack():
- self.__hmac_send = hmac.HMAC(sesskey, digestmod=sha)
- self.__hmac_recv = hmac.HMAC(sesskey, digestmod=sha)
+ self.__hmac_send = hmac.HMAC(sesskey, digestmod=ZEO.hash)
+ self.__hmac_recv = hmac.HMAC(sesskey, digestmod=ZEO.hash)
if False:
yield ''
Modified: ZODB/trunk/src/ZODB/POSException.py
===================================================================
--- ZODB/trunk/src/ZODB/POSException.py 2009-03-30 20:41:26 UTC (rev 98630)
+++ ZODB/trunk/src/ZODB/POSException.py 2009-03-30 20:44:57 UTC (rev 98631)
@@ -15,6 +15,8 @@
$Id$"""
+import sys
+
from ZODB.utils import oid_repr, readable_tid_repr
# BBB: We moved the two transactions to the transaction package
@@ -34,22 +36,38 @@
class POSError(StandardError):
"""Persistent object system error."""
- def __reduce__(self):
- # Cope extra data from internal structures
- state = self.__dict__.copy()
- state['message'] = self.message
- state['args'] = self.args
+ 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
- return (_recon, (self.__class__, state))
+ def __get_message(self):
+ return self.__dict__['message']
-class POSKeyError(KeyError, POSError):
+ 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):
+ # Copy extra data from internal structures
+ state = self.__dict__.copy()
+ if sys.version_info[:2] == (2, 5):
+ state['message'] = self.message
+ state['args'] = self.args
+
+ return (_recon, (self.__class__, state))
+
+class POSKeyError(POSError, KeyError):
"""Key not found in database."""
def __str__(self):
return oid_repr(self.args[0])
-class ConflictError(TransactionError):
+class ConflictError(POSError, TransactionError):
"""Two transactions tried to modify the same object at once.
This transaction should be resubmitted.
@@ -213,7 +231,7 @@
return "BTrees conflict error at %d/%d/%d: %s" % (
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.
If an object is stored and it has a reference to another object
More information about the Zodb-checkins
mailing list