diff roundup/hyperdb.py @ 8305:a81a3cd067fa

Generate savepoint only if necessary Now some methods got an additional 'allow_abort' parameter. By default this is True. When False the postgres backend generates a savepoint. The methods are called with allow_abort=False from some of the cgi methods which can produce a traceback when called with data from the web-interface.
author Ralf Schlatterbeck <rsc@runtux.com>
date Sat, 01 Mar 2025 18:55:54 +0100
parents 24549122f9b1
children 370689471a08
line wrap: on
line diff
--- a/roundup/hyperdb.py	Sat Mar 01 13:08:09 2025 +0100
+++ b/roundup/hyperdb.py	Sat Mar 01 18:55:54 2025 +0100
@@ -1065,10 +1065,12 @@
         """
         return node
 
-    def getnode(self, classname, nodeid):
+    def getnode(self, classname, nodeid, allow_abort=True):
         """Get a node from the database.
 
         'cache' exists for backwards compatibility, and is not used.
+        'allow_abort' determines if we allow that the current
+        transaction is aborted due to a data error (e.g. invalid nodeid).
         """
         raise NotImplementedError
 
@@ -1235,7 +1237,7 @@
         """
         raise NotImplementedError
 
-    def get(self, nodeid, propname, default=_marker, cache=1):
+    def get(self, nodeid, propname, default=_marker, cache=1, allow_abort=True):
         """Get the value of a property on an existing node of this class.
 
         'nodeid' must be the id of an existing node of this class or an
@@ -1243,6 +1245,8 @@
         of this class or a KeyError is raised.
 
         'cache' exists for backwards compatibility, and is not used.
+        'allow_abort' determines if we allow that the current
+        transaction is aborted due to a data error (e.g. invalid nodeid).
         """
         raise NotImplementedError
 
@@ -1300,8 +1304,10 @@
         """
         raise NotImplementedError
 
-    def is_retired(self, nodeid):
+    def is_retired(self, nodeid, allow_abort=True):
         """Return true if the node is rerired
+           'allow_abort' specifies if we allow the transaction to be
+           aborted if a syntactically invalid nodeid is passed.
         """
         raise NotImplementedError
 
@@ -2182,10 +2188,13 @@
         ensureParentsExist(dest)
         shutil.copyfile(source, dest)
 
-    def get(self, nodeid, propname, default=_marker, cache=1):
+    def get(self, nodeid, propname, default=_marker, cache=1, allow_abort=True):
         """ Trap the content propname and get it from the file
 
         'cache' exists for backwards compatibility, and is not used.
+
+        'allow_abort' determines if we allow that the current
+        transaction is aborted due to a data error (e.g. invalid nodeid).
         """
         poss_msg = 'Possibly an access right configuration problem.'
         if propname == 'content':
@@ -2212,9 +2221,11 @@
             return self.db.getfile(self.classname, nodeid, None)
 
         if default is not _marker:
-            return self.subclass.get(self, nodeid, propname, default)
+            return self.subclass.get(self, nodeid, propname, default,
+                                     allow_abort=allow_abort)
         else:
-            return self.subclass.get(self, nodeid, propname)
+            return self.subclass.get(self, nodeid, propname,
+                                     allow_abort=allow_abort)
 
     def import_files(self, dirname, nodeid):
         """ Import the "content" property as a file

Roundup Issue Tracker: http://roundup-tracker.org/