Roundup Tracker - Issues

Message5773

Author rouilj
Recipients rouilj
Date 2016-07-07.02:04:38
Message-id <1467857079.7.0.753572009232.issue2550923@psf.upfronthosting.co.za>
In-reply-to
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.
History
Date User Action Args
2016-07-07 02:04:39rouiljsetrecipients: + rouilj
2016-07-07 02:04:39rouiljsetmessageid: <1467857079.7.0.753572009232.issue2550923@psf.upfronthosting.co.za>
2016-07-07 02:04:39rouiljlinkissue2550923 messages
2016-07-07 02:04:38rouiljcreate