[Zope3-checkins] CVS: ZODB4/ZODB - lock_file.py:1.7

Jeremy Hylton jeremy@zope.com
Thu, 18 Jul 2002 18:31:40 -0400


Update of /cvs-repository/ZODB4/ZODB
In directory cvs.zope.org:/tmp/cvs-serv24603

Modified Files:
	lock_file.py 
Log Message:
Report the name of the file in the lock error.


=== ZODB4/ZODB/lock_file.py 1.6 => 1.7 ===
 # FOR A PARTICULAR PURPOSE.
 # 
 ##############################################################################
-import POSException
+from ZODB.POSException import StorageSystemError
 
 # Try to create a function that creates Unix file locks.  On windows
 # this will fail.
@@ -20,37 +20,31 @@
 
     lock_file_FLAG = fcntl.LOCK_EX | fcntl.LOCK_NB
 
-    def lock_file(file, error=POSException.StorageSystemError):
+    def lock_file(file, error=StorageSystemError):
         try:
-            un=file.fileno()
+            un = file.fileno()
         except:
             return # don't care if not a real file
 
         try:
             fcntl.flock(un,lock_file_FLAG)
         except:
-            raise error, (
-                "Could not lock the database file.  There must be\n"
-                "another process that has opened the file.\n"
-                "<p>")
+            raise error("Could not lock %s" % file.name)
 
 except:
     # Try windows-specific code:
     try:
         from winlock import LockFile
-        def lock_file(file, error=POSException.StorageSystemError):
+        def lock_file(file, error=StorageSystemError):
             try:
-                un=file.fileno()
+                un = file.fileno()
             except:
                 return # don't care if not a real file
             
             try:
-                LockFile(un,0,0,1,0) # just lock the first byte, who cares
+                LockFile(un, 0, 0, 1, 0) # just lock the first byte, who cares
             except:
-                raise error, (
-                    "Could not lock the database file.  There must be\n"
-                    "another process that has opened the file.\n"
-                    "<p>")            
+                raise error("Could not lock %s" % file.name)
     except:
         def lock_file(file, error=None):
             pass