diff roundup/backends/rdbms_common.py @ 6292:1e5ed659e8ca issue2550923_computed_property

Initial implementation of Computed property It supports query/display in html, rest and xml interfaces. You can specify a cache parameter, but using it raises NotImplementedError. It does not support: search, sort or grouping by the computed field. Checking in on a branch to get more eyeballs on it and maybe some people to help.
author John Rouillard <rouilj@ieee.org>
date Fri, 27 Nov 2020 18:09:00 -0500
parents 6834bb5473da
children 30358e334232
line wrap: on
line diff
--- a/roundup/backends/rdbms_common.py	Fri Nov 27 17:55:52 2020 -0500
+++ b/roundup/backends/rdbms_common.py	Fri Nov 27 18:09:00 2020 -0500
@@ -57,7 +57,7 @@
 # roundup modules
 from roundup import hyperdb, date, password, roundupdb, security, support
 from roundup.hyperdb import String, Password, Date, Interval, Link, \
-    Multilink, DatabaseError, Boolean, Number, Integer
+    Multilink, DatabaseError, Boolean, Computed, Number, Integer
 from roundup.i18n import _
 
 # support
@@ -1780,6 +1780,9 @@
         # get the property (raises KeyError if invalid)
         prop = self.properties[propname]
 
+        if isinstance(prop, Computed):
+            return prop.function(prop, nodeid, self.db)
+
         # lazy evaluation of Multilink
         if propname not in d and isinstance(prop, Multilink):
             self.db._materialize_multilink(self.classname, nodeid, d, propname)

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