22Customising Roundup
33===================
44
5- :Version: $Revision: 1.220 $
5+ :Version: $Revision: 1.221 $
66
77.. This document borrows from the ZopeBook section on ZPT. The original is at:
88 http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx
@@ -445,7 +445,7 @@ specifying (default) labelling and ordering of classes.)::
445445
446446 file = FileClass(db, "file", name=String())
447447
448- issue = IssueClass(db, "issue", topic =Multilink("keyword"),
448+ issue = IssueClass(db, "issue", keyword =Multilink("keyword"),
449449 status=Link("status"), assignedto=Link("user"),
450450 priority=Link("priority"))
451451 issue.setkey('title')
@@ -2481,10 +2481,10 @@ An index view specifier (URL fragment) looks like this (whitespace has
24812481been added for clarity)::
24822482
24832483 /issue?status=unread,in-progress,resolved&
2484- topic =security,ui&
2484+ keyword =security,ui&
24852485 @group=priority,-status&
24862486 @sort=-activity&
2487- @filters=status,topic &
2487+ @filters=status,keyword &
24882488 @columns=title,status,fixer
24892489
24902490The index view is determined by two parts of the specifier: the layout
@@ -2503,11 +2503,11 @@ of items with values matching any specified Multilink properties.
25032503
25042504The example specifies an index of "issue" items. Only items with a
25052505"status" of either "unread" or "in-progress" or "resolved" are
2506- displayed, and only items with "topic " values including both "security"
2506+ displayed, and only items with "keyword " values including both "security"
25072507and "ui" are displayed. The items are grouped by priority arranged in
25082508ascending order and in descending order by status; and within
25092509groups, sorted by activity, arranged in descending order. The filter
2510- section shows filters for the "status" and "topic " properties, and the
2510+ section shows filters for the "status" and "keyword " properties, and the
25112511table includes columns for the "title", "status", and "fixer"
25122512properties.
25132513
@@ -2904,7 +2904,7 @@ caches the schema).
290429041. Modify the ``schema.py``::
29052905
29062906 issue = IssueClass(db, "issue",
2907- assignedto=Link("user"), topic =Multilink("keyword"),
2907+ assignedto=Link("user"), keyword =Multilink("keyword"),
29082908 priority=Link("priority"), status=Link("status"),
29092909 due_date=Date())
29102910
@@ -3398,7 +3398,7 @@ be able to give a summary of the total time spent on a particular issue.
33983398 ``schema.py``)::
33993399
34003400 issue = IssueClass(db, "issue",
3401- assignedto=Link("user"), topic =Multilink("keyword"),
3401+ assignedto=Link("user"), keyword =Multilink("keyword"),
34023402 priority=Link("priority"), status=Link("status"),
34033403 times=Multilink("timelog"))
34043404
@@ -3571,7 +3571,7 @@ a system support issue class to a tracker.
35713571
35723572 # store issues related to those systems
35733573 support = IssueClass(db, "support",
3574- assignedto=Link("user"), topic =Multilink("keyword"),
3574+ assignedto=Link("user"), keyword =Multilink("keyword"),
35753575 status=Link("status"), deadline=Date(),
35763576 affects=Multilink("system"))
35773577
@@ -4055,14 +4055,14 @@ resolved. To achieve this:
40554055 this class in your tracker's ``schema.py`` file. Change this::
40564056
40574057 issue = IssueClass(db, "issue",
4058- assignedto=Link("user"), topic =Multilink("keyword"),
4058+ assignedto=Link("user"), keyword =Multilink("keyword"),
40594059 priority=Link("priority"), status=Link("status"))
40604060
40614061 to this, adding the blockers entry::
40624062
40634063 issue = IssueClass(db, "issue",
40644064 blockers=Multilink("issue"),
4065- assignedto=Link("user"), topic =Multilink("keyword"),
4065+ assignedto=Link("user"), keyword =Multilink("keyword"),
40664066 priority=Link("priority"), status=Link("status"))
40674067
406840682. Add the new ``blockers`` property to the ``issue.item.html`` edit
@@ -4204,33 +4204,32 @@ on it (i.e. it's in their blockers list) you can look at the journal
42044204history at the bottom of the issue page - look for a "link" event to
42054205another issue's "blockers" property.
42064206
4207- Add users to the nosy list based on the topic
4208- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4207+ Add users to the nosy list based on the keyword
4208+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
42094209
42104210Let's say we need the ability to automatically add users to the nosy
42114211list based
4212- on the occurance of a topic . Every user should be allowed to edit their
4213- own list of topics for which they want to be added to the nosy list.
4212+ on the occurance of a keyword . Every user should be allowed to edit their
4213+ own list of keywords for which they want to be added to the nosy list.
42144214
42154215Below, we'll show that this change can be done with minimal
42164216understanding of the Roundup system, using only copy and paste.
42174217
42184218This requires three changes to the tracker: a change in the database to
4219- allow per-user recording of the lists of topics for which he wants to
4219+ allow per-user recording of the lists of keywords for which he wants to
42204220be put on the nosy list, a change in the user view allowing them to edit
4221- this list of topics , and addition of an auditor which updates the nosy
4222- list when a topic is set.
4221+ this list of keywords , and addition of an auditor which updates the nosy
4222+ list when a keyword is set.
42234223
4224- Adding the nosy topic list
4225- ::::::::::::::::::::::::::
4224+ Adding the nosy keyword list
4225+ ::::::::::::::::::::::::::::
42264226
4227- The change to make in the database, is that for any user there should be
4228- a list of topics for which he wants to be put on the nosy list. Adding
4229- a ``Multilink`` of ``keyword`` seems to fullfill this (note that within
4230- the code, topics are called ``keywords``.) As such, all that has to be
4231- done is to add a new field to the definition of ``user`` within the
4232- file ``schema.py``. We will call this new field ``nosy_keywords``, and
4233- the updated definition of user will be::
4227+ The change to make in the database, is that for any user there should be a list
4228+ of keywords for which he wants to be put on the nosy list. Adding a
4229+ ``Multilink`` of ``keyword`` seems to fullfill this. As such, all that has to
4230+ be done is to add a new field to the definition of ``user`` within the file
4231+ ``schema.py``. We will call this new field ``nosy_keywords``, and the updated
4232+ definition of user will be::
42344233
42354234 user = Class(db, "user",
42364235 username=String(), password=Password(),
@@ -4241,22 +4240,22 @@ the updated definition of user will be::
42414240 timezone=String(),
42424241 nosy_keywords=Multilink('keyword'))
42434242
4244- Changing the user view to allow changing the nosy topic list
4245- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
4243+ Changing the user view to allow changing the nosy keyword list
4244+ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
42464245
4247- We want any user to be able to change the list of topics for which
4246+ We want any user to be able to change the list of keywords for which
42484247he will by default be added to the nosy list. We choose to add this
42494248to the user view, as is generated by the file ``html/user.item.html``.
42504249We can easily
4251- see that the topic field in the issue view has very similar editing
4252- requirements as our nosy topics , both being lists of topics . As
4253- such, we look for Topics in ``issue.item.html``, and extract the
4250+ see that the keyword field in the issue view has very similar editing
4251+ requirements as our nosy keywords , both being lists of keywords . As
4252+ such, we look for Keywords in ``issue.item.html``, and extract the
42544253associated parts from there. We add this to ``user.item.html`` at the
42554254bottom of the list of viewed items (i.e. just below the 'Alternate
42564255E-mail addresses' in the classic template)::
42574256
42584257 <tr>
4259- <th>Nosy Topics </th>
4258+ <th>Nosy Keywords </th>
42604259 <td>
42614260 <span tal:replace="structure context/nosy_keywords/field" />
42624261 <span tal:replace="structure python:db.keyword.classhelp(property='nosy_keywords')" />
@@ -4269,7 +4268,7 @@ Addition of an auditor to update the nosy list
42694268
42704269The more difficult part is the logic to add
42714270the users to the nosy list when required.
4272- We choose to perform this action whenever the topics on an
4271+ We choose to perform this action whenever the keywords on an
42734272item are set (this includes the creation of items).
42744273Here we choose to start out with a copy of the
42754274``detectors/nosyreaction.py`` detector, which we copy to the file
@@ -4290,16 +4289,16 @@ functionality is left in the new auditor. The following block of
42904289code, which handled adding the assignedto user(s) to the nosy list in
42914290``updatenosy``, should be replaced by a block of code to add the
42924291interested users to the nosy list. We choose here to loop over all
4293- new topics , than looping over all users,
4294- and assign the user to the nosy list when the topic occurs in the user's
4292+ new keywords , than looping over all users,
4293+ and assign the user to the nosy list when the keyword occurs in the user's
42954294``nosy_keywords``. The next part in ``updatenosy`` -- adding the author
42964295and/or recipients of a message to the nosy list -- is obviously not
42974296relevant here and is thus deleted from the new auditor. The last
42984297part, copying the new nosy list to ``newvalues``, can stay as is.
42994298This results in the following function::
43004299
43014300 def update_kw_nosy(db, cl, nodeid, newvalues):
4302- '''Update the nosy list for changes to the topics
4301+ '''Update the nosy list for changes to the keywords
43034302 '''
43044303 # nodeid will be None if this is a new node
43054304 current = {}
@@ -4324,17 +4323,17 @@ This results in the following function::
43244323 if not current.has_key(value):
43254324 current[value] = 1
43264325
4327- # add users with topic in nosy_keywords to the nosy list
4328- if newvalues.has_key('topic ') and newvalues['topic '] is not None:
4329- topic_ids = newvalues['topic ']
4330- for topic in topic_ids :
4326+ # add users with keyword in nosy_keywords to the nosy list
4327+ if newvalues.has_key('keyword ') and newvalues['keyword '] is not None:
4328+ keyword_ids = newvalues['keyword ']
4329+ for keyword in keyword_ids :
43314330 # loop over all users,
4332- # and assign user to nosy when topic in nosy_keywords
4331+ # and assign user to nosy when keyword in nosy_keywords
43334332 for user_id in db.user.list():
43344333 nosy_kw = db.user.get(user_id, "nosy_keywords")
43354334 found = 0
43364335 for kw in nosy_kw:
4337- if kw == topic :
4336+ if kw == keyword :
43384337 found = 1
43394338 if found:
43404339 current[user_id] = 1
@@ -4354,10 +4353,10 @@ A few problems with the design here can be noted:
43544353Multiple additions
43554354 When a user, after automatic selection, is manually removed
43564355 from the nosy list, he is added to the nosy list again when the
4357- topic list of the issue is updated. A better design might be
4358- to only check which topics are new compared to the old list
4359- of topics , and only add users when they have indicated
4360- interest on a new topic .
4356+ keyword list of the issue is updated. A better design might be
4357+ to only check which keywords are new compared to the old list
4358+ of keywords , and only add users when they have indicated
4359+ interest on a new keyword .
43614360
43624361 The code could also be changed to only trigger on the ``create()``
43634362 event, rather than also on the ``set()`` event, thus only setting
@@ -4367,8 +4366,8 @@ Scalability
43674366 In the auditor, there is a loop over all users. For a site with
43684367 only few users this will pose no serious problem; however, with
43694368 many users this will be a serious performance bottleneck.
4370- A way out would be to link from the topics to the users who
4371- selected these topics as nosy topics . This will eliminate the
4369+ A way out would be to link from the keywords to the users who
4370+ selected these keywords as nosy keywords . This will eliminate the
43724371 loop over all users.
43734372
43744373Changes to Security and Permissions
0 commit comments