Quantcast

[issue2550923] Create new Computed property type

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[issue2550923] Create new Computed property type

John Rouillard

New submission from John Rouillard:

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.

----------
keywords: Effort-High, GSOC
messages: 5773
nosy: rouilj
priority: normal
severity: normal
status: new
title: Create new Computed property type
type: rfe

________________________________________________
Roundup tracker <[hidden email]>
<http://issues.roundup-tracker.org/issue2550923>
________________________________________________

------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
Roundup-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/roundup-devel
Loading...