Created on 2016-07-07 02:04 by rouilj, last changed 2016-07-15 11:13 by antmail.
|msg5773||Author: [hidden] (rouilj)||Date: 2016-07-07 02:04|
At: https://sourceforge.net/p/roundup/mailman/message/34268641/ is a discussion of computed properties for a class. Use case: suppose you wanted to have a count of the number of messages in an issue. You can add a msg_count: issue = IssueClass(db,'issue', .... msg_count = Number() to the issue, but then you need an auditor to keep the count up to date, and it has to run on every msg update even if nobody ever asks for the msg_count. Suppose you could instead add: msg_count = Computed("countIssueMessages") When somebody does a db.issue.get(id, 'msg_count') the function: countIssueMessages(InstanceOfIssueClass, db) is invoked. Then in schema.py (or lib/) I define: Class Computed: def countIssueMessages(Myissue, db): return Myissue['msgs'].count() Use Case: this could be used for getting the user phone number from an external address book by changing the user schema to read: user = Class(db, "user", ... phone=Computed("getPhoneFromLdap") then: def getPhoneFromLdap(Myuser, db): return lookupPhoneGivenUser(Myuser['username']) So this way there is no need to "sync" a bunch of data from an external source into roundup. Design etc. TBD. But I wanted to get this in the tracker as it seems it may be a good summer of code idea for the future. Note that there is no way to set the properties, they are strictly read only at this time.
|msg5858||Author: [hidden] (antmail)||Date: 2016-07-15 11:13|
> At: https://sourceforge.net/p/roundup/mailman/message/34268641/ > is a discussion of computed properties for a class. I think this is very interesting issue. I think we must discuss a design and future direction of roundup-tracker. There are my raw thoughts. I think that a ReadOnly properties is more suitable to roundup-tracker conception than Computed. Firstly it can be typified and then used in template as usual. The example of external address book will look like: user = Class(db, "user", ... phone=ROString("getPhoneFromLdap") ... then: def getPhoneFromLdap(MyUser): return lookupPhoneGivenUser(Myuser['username'])
messages: + msg5858
|2016-07-12 15:34:14||schlatterbeck||set||nosy: + schlatterbeck|