acc555d64cf0b8cf99cc211e13244e2e01cf71ec
1 ===================
2 Customising Roundup
3 ===================
5 :Version: $Revision: 1.27 $
7 .. This document borrows from the ZopeBook section on ZPT. The original is at:
8 http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx
10 .. contents::
13 What You Can Do
14 ===============
16 Customisation of Roundup can take one of five forms:
18 1. `tracker configuration`_ file changes
19 2. database, or `tracker schema`_ changes
20 3. "definition" class `database content`_ changes
21 4. behavioural changes, through detectors_
22 5. `access controls`_
24 The third case is special because it takes two distinctly different forms
25 depending upon whether the tracker has been initialised or not. The other two
26 may be done at any time, before or after tracker initialisation. Yes, this
27 includes adding or removing properties from classes.
30 Trackers in a Nutshell
31 ======================
33 Trackers have the following structure:
35 =================== ========================================================
36 Tracker File Description
37 =================== ========================================================
38 config.py Holds the basic `tracker configuration`_
39 dbinit.py Holds the `tracker schema`_
40 interfaces.py Defines the Web and E-Mail interfaces for the tracker
41 select_db.py Selects the database back-end for the tracker
42 db/ Holds the tracker's database
43 db/files/ Holds the tracker's upload files and messages
44 detectors/ Auditors and reactors for this tracker
45 html/ Web interface templates, images and style sheets
46 =================== ========================================================
48 Tracker Configuration
49 =====================
51 The config.py located in your tracker home contains the basic
52 configuration for the web and e-mail components of roundup's interfaces. This
53 file is a Python module. The configuration variables available are:
55 **TRACKER_HOME** - ``os.path.split(__file__)[0]``
56 The tracker home directory. The above default code will automatically
57 determine the tracker home for you.
59 **MAILHOST** - ``'localhost'``
60 The SMTP mail host that roundup will use to send e-mail.
62 **MAIL_DOMAIN** - ``'your.tracker.email.domain.example'``
63 The domain name used for email addresses.
65 **DATABASE** - ``os.path.join(TRACKER_HOME, 'db')``
66 This is the directory that the database is going to be stored in. By default
67 it is in the tracker home.
69 **TEMPLATES** - ``os.path.join(TRACKER_HOME, 'html')``
70 This is the directory that the HTML templates reside in. By default they are
71 in the tracker home.
73 **TRACKER_NAME** - ``'Roundup issue tracker'``
74 A descriptive name for your roundup tracker. This is sent out in e-mails and
75 appears in the heading of CGI pages.
77 **TRACKER_EMAIL** - ``'issue_tracker@%s'%MAIL_DOMAIN``
78 The email address that e-mail sent to roundup should go to. Think of it as the
79 tracker's personal e-mail address.
81 **TRACKER_WEB** - ``'http://your.tracker.url.example/'``
82 The web address that the tracker is viewable at. This will be included in
83 information sent to users of the tracker.
85 **ADMIN_EMAIL** - ``'roundup-admin@%s'%MAIL_DOMAIN``
86 The email address that roundup will complain to if it runs into trouble.
88 **MESSAGES_TO_AUTHOR** - ``'yes'`` or``'no'``
89 Send nosy messages to the author of the message.
91 **ADD_AUTHOR_TO_NOSY** - ``'new'``, ``'yes'`` or ``'no'``
92 Does the author of a message get placed on the nosy list automatically?
93 If ``'new'`` is used, then the author will only be added when a message
94 creates a new issue. If ``'yes'``, then the author will be added on followups
95 too. If ``'no'``, they're never added to the nosy.
97 **ADD_RECIPIENTS_TO_NOSY** - ``'new'``, ``'yes'`` or ``'no'``
98 Do the recipients (To:, Cc:) of a message get placed on the nosy list?
99 If ``'new'`` is used, then the recipients will only be added when a message
100 creates a new issue. If ``'yes'``, then the recipients will be added on
101 followups too. If ``'no'``, they're never added to the nosy.
103 **EMAIL_SIGNATURE_POSITION** - ``'top'``, ``'bottom'`` or ``'none'``
104 Where to place the email signature in messages that Roundup generates.
106 **EMAIL_KEEP_QUOTED_TEXT** - ``'yes'`` or ``'no'``
107 Keep email citations. Citations are the part of e-mail which the sender has
108 quoted in their reply to previous e-mail.
110 **EMAIL_LEAVE_BODY_UNCHANGED** - ``'no'``
111 Preserve the email body as is. Enabiling this will cause the entire message
112 body to be stored, including all citations and signatures. It should be
113 either ``'yes'`` or ``'no'``.
115 **MAIL_DEFAULT_CLASS** - ``'issue'`` or ``''``
116 Default class to use in the mailgw if one isn't supplied in email
117 subjects. To disable, comment out the variable below or leave it blank.
119 The default config.py is given below - as you
120 can see, the MAIL_DOMAIN must be edited before any interaction with the
121 tracker is attempted.::
123 # roundup home is this package's directory
124 TRACKER_HOME=os.path.split(__file__)[0]
126 # The SMTP mail host that roundup will use to send mail
127 MAILHOST = 'localhost'
129 # The domain name used for email addresses.
130 MAIL_DOMAIN = 'your.tracker.email.domain.example'
132 # This is the directory that the database is going to be stored in
133 DATABASE = os.path.join(TRACKER_HOME, 'db')
135 # This is the directory that the HTML templates reside in
136 TEMPLATES = os.path.join(TRACKER_HOME, 'html')
138 # A descriptive name for your roundup tracker
139 TRACKER_NAME = 'Roundup issue tracker'
141 # The email address that mail to roundup should go to
142 TRACKER_EMAIL = 'issue_tracker@%s'%MAIL_DOMAIN
144 # The web address that the tracker is viewable at
145 TRACKER_WEB = 'http://your.tracker.url.example/'
147 # The email address that roundup will complain to if it runs into trouble
148 ADMIN_EMAIL = 'roundup-admin@%s'%MAIL_DOMAIN
150 # Send nosy messages to the author of the message
151 MESSAGES_TO_AUTHOR = 'no' # either 'yes' or 'no'
153 # Does the author of a message get placed on the nosy list automatically?
154 # If 'new' is used, then the author will only be added when a message
155 # creates a new issue. If 'yes', then the author will be added on followups
156 # too. If 'no', they're never added to the nosy.
157 ADD_AUTHOR_TO_NOSY = 'new' # one of 'yes', 'no', 'new'
159 # Do the recipients (To:, Cc:) of a message get placed on the nosy list?
160 # If 'new' is used, then the recipients will only be added when a message
161 # creates a new issue. If 'yes', then the recipients will be added on followups
162 # too. If 'no', they're never added to the nosy.
163 ADD_RECIPIENTS_TO_NOSY = 'new' # either 'yes', 'no', 'new'
165 # Where to place the email signature
166 EMAIL_SIGNATURE_POSITION = 'bottom' # one of 'top', 'bottom', 'none'
168 # Keep email citations
169 EMAIL_KEEP_QUOTED_TEXT = 'no' # either 'yes' or 'no'
171 # Preserve the email body as is
172 EMAIL_LEAVE_BODY_UNCHANGED = 'no' # either 'yes' or 'no'
174 # Default class to use in the mailgw if one isn't supplied in email
175 # subjects. To disable, comment out the variable below or leave it blank.
176 # Examples:
177 MAIL_DEFAULT_CLASS = 'issue' # use "issue" class by default
178 #MAIL_DEFAULT_CLASS = '' # disable (or just comment the var out)
180 Tracker Schema
181 ==============
183 Note: if you modify the schema, you'll most likely need to edit the
184 `web interface`_ HTML template files and `detectors`_ to reflect
185 your changes.
187 A tracker schema defines what data is stored in the tracker's database.
188 The
189 schemas shipped with Roundup turn it into a typical software bug tracker or
190 help desk.
192 XXX make sure we ship the help desk
194 Schemas are defined using Python code in the ``dbinit.py`` module of your
195 tracker. The "classic" schema looks like this::
197 pri = Class(db, "priority", name=String(), order=String())
198 pri.setkey("name")
199 pri.create(name="critical", order="1")
200 pri.create(name="urgent", order="2")
201 pri.create(name="bug", order="3")
202 pri.create(name="feature", order="4")
203 pri.create(name="wish", order="5")
205 stat = Class(db, "status", name=String(), order=String())
206 stat.setkey("name")
207 stat.create(name="unread", order="1")
208 stat.create(name="deferred", order="2")
209 stat.create(name="chatting", order="3")
210 stat.create(name="need-eg", order="4")
211 stat.create(name="in-progress", order="5")
212 stat.create(name="testing", order="6")
213 stat.create(name="done-cbb", order="7")
214 stat.create(name="resolved", order="8")
216 keyword = Class(db, "keyword", name=String())
217 keyword.setkey("name")
219 user = Class(db, "user", username=String(), password=String(),
220 address=String(), realname=String(), phone=String(),
221 organisation=String())
222 user.setkey("username")
223 user.create(username="admin", password=adminpw,
224 address=config.ADMIN_EMAIL)
226 msg = FileClass(db, "msg", author=Link("user"), recipients=Multilink
227 ("user"), date=Date(), summary=String(), files=Multilink("file"))
229 file = FileClass(db, "file", name=String(), type=String())
231 issue = IssueClass(db, "issue", assignedto=Link("user"),
232 topic=Multilink("keyword"), priority=Link("priority"), status=Link
233 ("status"))
234 issue.setkey('title')
236 XXX security definitions
238 Classes and Properties - creating a new information store
239 ---------------------------------------------------------
241 In the tracker above, we've defined 7 classes of information:
243 priority
244 Defines the possible levels of urgency for issues.
246 status
247 Defines the possible states of processing the issue may be in.
249 keyword
250 Initially empty, will hold keywords useful for searching issues.
252 user
253 Initially holding the "admin" user, will eventually have an entry for all
254 users using roundup.
256 msg
257 Initially empty, will all e-mail messages sent to or generated by
258 roundup.
260 file
261 Initially empty, will all files attached to issues.
263 issue
264 Initially empty, this is where the issue information is stored.
266 We define the "priority" and "status" classes to allow two things: reduction in
267 the amount of information stored on the issue and more powerful, accurate
268 searching of issues by priority and status. By only requiring a link on the
269 issue (which is stored as a single number) we reduce the chance that someone
270 mis-types a priority or status - or simply makes a new one up.
272 Class and Items
273 ~~~~~~~~~~~~~~~
275 A Class defines a particular class (or type) of data that will be stored in the
276 database. A class comprises one or more properties, which given the information
277 about the class items.
278 The actual data entered into the database, using class.create() are called
279 items. They have a special immutable property called id. We sometimes refer to
280 this as the itemid.
282 Properties
283 ~~~~~~~~~~
285 A Class is comprised of one or more properties of the following types:
287 * String properties are for storing arbitrary-length strings.
288 * Password properties are for storing encoded arbitrary-length strings. The
289 default encoding is defined on the roundup.password.Password class.
290 * Date properties store date-and-time stamps. Their values are Timestamp
291 objects.
292 * Number properties store numeric values.
293 * Boolean properties store on/off, yes/no, true/false values.
294 * A Link property refers to a single other item selected from a specified
295 class. The class is part of the property; the value is an integer, the id
296 of the chosen item.
297 * A Multilink property refers to possibly many items in a specified class.
298 The value is a list of integers.
300 FileClass
301 ~~~~~~~~~
303 FileClasses save their "content" attribute off in a separate file from the rest
304 of the database. This reduces the number of large entries in the database,
305 which generally makes databases more efficient, and also allows us to use
306 command-line tools to operate on the files. They are stored in the files sub-
307 directory of the db directory in your tracker.
309 IssueClass
310 ~~~~~~~~~~
312 IssueClasses automatically include the "messages", "files", "nosy", and
313 "superseder" properties.
314 The messages and files properties list the links to the messages and files
315 related to the issue. The nosy property is a list of links to users who wish to
316 be informed of changes to the issue - they get "CC'ed" e-mails when messages
317 are sent to or generated by the issue. The nosy reactor (in the detectors
318 directory) handles this action. The superceder link indicates an issue which
319 has superceded this one.
320 They also have the dynamically generated "creation", "activity" and "creator"
321 properties.
322 The value of the "creation" property is the date when an item was created, and
323 the value of the "activity" property is the date when any property on the item
324 was last edited (equivalently, these are the dates on the first and last
325 records in the item's journal). The "creator" property holds a link to the user
326 that created the issue.
328 setkey(property)
329 ~~~~~~~~~~~~~~~~
331 Select a String property of the class to be the key property. The key property
332 muse be unique, and allows references to the items in the class by the content
333 of the key property. That is, we can refer to users by their username, e.g.
334 let's say that there's an issue in roundup, issue 23. There's also a user,
335 richard who happens to be user 2. To assign an issue to him, we could do either
336 of::
338 roundup-admin set issue assignedto=2
340 or::
342 roundup-admin set issue assignedto=richard
344 Note, the same thing can be done in the web and e-mail interfaces.
346 create(information)
347 ~~~~~~~~~~~~~~~~~~~
349 Create an item in the database. This is generally used to create items in the
350 "definitional" classes like "priority" and "status".
353 Examples of adding to your schema
354 ---------------------------------
356 TODO
359 Detectors - adding behaviour to your tracker
360 ============================================
361 .. _detectors:
363 The detectors in your tracker fire before (*auditors*) and after (*reactors*)
364 changes to the contents of your database. They are Python modules that sit in
365 your tracker's ``detectors`` directory. You will have some installed by
366 default - have a look. You can write new detectors or modify the existing
367 ones. The existing detectors installed for you are:
369 **nosyreaction.py**
370 This provides the automatic nosy list maintenance and email sending. The nosy
371 reactor (``nosyreaction``) fires when new messages are added to issues.
372 The nosy auditor (``updatenosy``) fires when issues are changed and figures
373 what changes need to be made to the nosy list (like adding new authors etc)
374 **statusauditor.py**
375 This provides the ``chatty`` auditor which changes the issue status from
376 ``unread`` or ``closed`` to ``chatting`` if new messages appear. It also
377 provides the ``presetunread`` auditor which pre-sets the status to
378 ``unread`` on new items if the status isn't explicitly defined.
380 See the detectors section in the `design document`__ for details of the
381 interface for detectors.
383 __ design.html
385 Sample additional detectors that have been found useful will appear in the
386 ``detectors`` directory of the Roundup distribution:
388 **newissuecopy.py**
389 This detector sends an email to a team address whenever a new issue is
390 created. The address is hard-coded into the detector, so edit it before you
391 use it (look for the text 'team@team.host') or you'll get email errors!
393 The detector code::
395 from roundup import roundupdb
397 def newissuecopy(db, cl, nodeid, oldvalues):
398 ''' Copy a message about new issues to a team address.
399 '''
400 # so use all the messages in the create
401 change_note = cl.generateCreateNote(nodeid)
403 # send a copy to the nosy list
404 for msgid in cl.get(nodeid, 'messages'):
405 try:
406 # note: last arg must be a list
407 cl.send_message(nodeid, msgid, change_note, ['team@team.host'])
408 except roundupdb.MessageSendError, message:
409 raise roundupdb.DetectorError, message
411 def init(db):
412 db.issue.react('create', newissuecopy)
415 Database Content
416 ================
418 Note: if you modify the content of definitional classes, you'll most likely
419 need to edit the tracker `detectors`_ to reflect your changes.
421 Customisation of the special "definitional" classes (eg. status, priority,
422 resolution, ...) may be done either before or after the tracker is
423 initialised. The actual method of doing so is completely different in each
424 case though, so be careful to use the right one.
426 **Changing content before tracker initialisation**
427 Edit the dbinit module in your tracker to alter the items created in using
428 the create() methods.
430 **Changing content after tracker initialisation**
431 Use the roundup-admin interface's create, set and retire methods to add,
432 alter or remove items from the classes in question.
434 XXX example
437 Web Interface
438 =============
440 The web is provided by the roundup.cgi.client module and is used by
441 roundup.cgi, roundup-server and ZRoundup.
442 In all cases, we determine which tracker is being accessed
443 (the first part of the URL path inside the scope of the CGI handler) and pass
444 control on to the tracker interfaces.Client class - which uses the Client class
445 from roundup.cgi.client - which handles the rest of
446 the access through its main() method. This means that you can do pretty much
447 anything you want as a web interface to your tracker.
449 Repurcussions of changing the tracker schema
450 ---------------------------------------------
452 If you choose to change the `tracker schema`_ you will need to ensure the web
453 interface knows about it:
455 1. Index, item and search pages for the relevant classes may need to have
456 properties added or removed,
457 2. The "page" template may require links to be changed, as might the "home"
458 page's content arguments.
460 How requests are processed
461 --------------------------
463 The basic processing of a web request proceeds as follows:
465 1. figure out who we are, defaulting to the "anonymous" user
466 2. figure out what the request is for - we call this the "context"
467 3. handle any requested action (item edit, search, ...)
468 4. render a template, resulting in HTML output
470 In some situations, exceptions occur:
472 - HTTP Redirect (generally raised by an action)
473 - SendFile (generally raised by determine_context)
474 here we serve up a FileClass "content" property
475 - SendStaticFile (generally raised by determine_context)
476 here we serve up a file from the tracker "html" directory
477 - Unauthorised (generally raised by an action)
478 here the action is cancelled, the request is rendered and an error
479 message is displayed indicating that permission was not
480 granted for the action to take place
481 - NotFound (raised wherever it needs to be)
482 this exception percolates up to the CGI interface that called the client
484 Determining web context
485 -----------------------
487 To determine the "context" of a request, we look at the URL and the special
488 request variable ``:template``. The URL path after the tracker identifier
489 is examined. Typical URL paths look like:
491 1. ``/tracker/issue``
492 2. ``/tracker/issue1``
493 3. ``/tracker/_file/style.css``
494 4. ``/cgi-bin/roundup.cgi/tracker/file1``
495 5. ``/cgi-bin/roundup.cgi/tracker/file1/kitten.png``
497 where the "tracker identifier" is "tracker" in the above cases. That means
498 we're looking at "issue", "issue1", "_file/style.css", "file1" and
499 "file1/kitten.png" in the cases above. The path is generally only one
500 entry long - longer paths are handled differently.
502 a. if there is no path, then we are in the "home" context.
503 b. if the path starts with "_file" (as in example 3,
504 "/tracker/_file/style.css"), then the additional path entry,
505 "style.css" specifies the filename of a static file we're to serve up
506 from the tracker "html" directory. Raises a SendStaticFile
507 exception.
508 c. if there is something in the path (as in example 1, "issue"), it identifies
509 the tracker class we're to display.
510 d. if the path is an item designator (as in examples 2 and 4, "issue1" and
511 "file1"), then we're to display a specific item.
512 e. if the path starts with an item designator and is longer than
513 one entry (as in example 5, "file1/kitten.png"), then we're assumed
514 to be handling an item of a
515 FileClass, and the extra path information gives the filename
516 that the client is going to label the download with (ie
517 "file1/kitten.png" is nicer to download than "file1"). This
518 raises a SendFile exception.
520 Both b. and e. stop before we bother to
521 determine the template we're going to use. That's because they
522 don't actually use templates.
524 The template used is specified by the ``:template`` CGI variable,
525 which defaults to:
527 - only classname suplied: "index"
528 - full item designator supplied: "item"
531 Performing actions in web requests
532 ----------------------------------
534 When a user requests a web page, they may optionally also request for an
535 action to take place. As described in `how requests are processed`_, the
536 action is performed before the requested page is generated. Actions are
537 triggered by using a ``:action`` CGI variable, where the value is one of:
539 login
540 Attempt to log a user in.
541 logout
542 Log the user out - make them "anonymous".
543 register
544 Attempt to create a new user based on the contents of the form and then log
545 them in.
546 edit
547 Perform an edit of an item in the database. There are some special form
548 elements you may use:
550 :link=designator:property and :multilink=designator:property
551 The value specifies an item designator and the property on that
552 item to add _this_ item to as a link or multilink.
553 :note
554 Create a message and attach it to the current item's
555 "messages" property.
556 :file
557 Create a file and attach it to the current item's
558 "files" property. Attach the file to the message created from
559 the :note if it's supplied.
560 :required=property,property,...
561 The named properties are required to be filled in the form.
563 new
564 Add a new item to the database. You may use the same special form elements
565 as in the "edit" action.
567 editCSV
568 Performs an edit of all of a class' items in one go. See also the
569 *class*.csv templating method which generates the CSV data to be edited, and
570 the "_generic.index" template which uses both of these features.
572 search
573 Mangle some of the form variables.
575 Set the form ":filter" variable based on the values of the
576 filter variables - if they're set to anything other than
577 "dontcare" then add them to :filter.
579 Also handle the ":queryname" variable and save off the query to
580 the user's query list.
582 Each of the actions is implemented by a corresponding *actionAction* (where
583 "action" is the name of the action) method on
584 the roundup.cgi.Client class, which also happens to be in your tracker as
585 interfaces.Client. So if you need to define new actions, you may add them
586 there (see `defining new web actions`_).
588 Each action also has a corresponding *actionPermission* (where
589 "action" is the name of the action) method which determines
590 whether the action is permissible given the current user. The base permission
591 checks are:
593 login
594 Determine whether the user has permission to log in.
595 Base behaviour is to check the user has "Web Access".
596 logout
597 No permission checks are made.
598 register
599 Determine whether the user has permission to register
600 Base behaviour is to check the user has "Web Registration".
601 edit
602 Determine whether the user has permission to edit this item.
603 Base behaviour is to check the user can edit this class. If we're
604 editing the "user" class, users are allowed to edit their own
605 details. Unless it's the "roles" property, which requires the
606 special Permission "Web Roles".
607 new
608 Determine whether the user has permission to create (edit) this item.
609 Base behaviour is to check the user can edit this class. No
610 additional property checks are made. Additionally, new user items
611 may be created if the user has the "Web Registration" Permission.
612 editCSV
613 Determine whether the user has permission to edit this class.
614 Base behaviour is to check the user can edit this class.
615 search
616 Determine whether the user has permission to search this class.
617 Base behaviour is to check the user can view this class.
620 Default templates
621 -----------------
623 Most customisation of the web view can be done by modifying the templates in
624 the tracker **html** directory. There are several types of files in there:
626 page
627 This template defines the overall look of your tracker. When you
628 view an issue, it appears inside this template. When you view an index, it
629 also appears inside this template. It will have a ``tal:content`` or
630 ``tal:replace`` command with the expression ``structure content`` which
631 will show the issue, list of issues or whatever.
632 home
633 the default page displayed when no other page is indicated by the user
634 home.classlist
635 a special version of the default page that lists the classes in the tracker
636 *classname*.item
637 displays an item of the *classname* class
638 *classname*.index
639 displays a list of *classname* items
640 *classname*.search
641 displays a search page for *classname* items
642 _generic.index
643 used to display a list of items where there is no *classname*.index available
644 _generic.help
645 used to display a "class help" page where there is no *classname*.help
646 user.register
647 a special page just for the user class that renders the registration page
648 style.css
649 a static file that is served up as-is
651 How the templates work
652 ----------------------
654 Roundup's templates consist of special attributes on your template tags. These
655 attributes form the Template Attribute Language, or TAL. The commands are:
658 tal:define="variable expression; variable expression; ..."
659 Define a new variable that is local to this tag and its contents. For
660 example::
662 <html tal:define="title request/description">
663 <head><title tal:content="title"></title></head>
664 </html>
666 In the example, the variable "title" is defined as being the result of the
667 expression "request/description". The tal:content command inside the <html>
668 tag may then use the "title" variable.
670 tal:condition="expression"
671 Only keep this tag and its contents if the expression is true. For example::
673 <p tal:condition="python:request.user.hasPermission('View', 'issue')">
674 Display some issue information.
675 </p>
677 In the example, the <p> tag and its contents are only displayed if the
678 user has the View permission for issues. We consider the number zero, a
679 blank string, an empty list, and the built-in variable nothing to be false
680 values. Nearly every other value is true, including non-zero numbers, and
681 strings with anything in them (even spaces!).
683 tal:repeat="variable expression"
684 Repeat this tag and its contents for each element of the sequence that the
685 expression returns, defining a new local variable and a special "repeat"
686 variable for each element. For example::
688 <tr tal:repeat="u user/list">
689 <td tal:content="u/id"></td>
690 <td tal:content="u/username"></td>
691 <td tal:content="u/realname"></td>
692 </tr>
694 The example would iterate over the sequence of users returned by
695 "user/list" and define the local variable "u" for each entry.
697 tal:replace="expression"
698 Replace this tag with the result of the expression. For example::
700 <span tal:replace="request/user/realname"></span>
702 The example would replace the <span> tag and its contents with the user's
703 realname. If the user's realname was "Bruce" then the resultant output
704 would be "Bruce".
706 tal:content="expression"
707 Replace the contents of this tag with the result of the expression. For
708 example::
710 <span tal:content="request/user/realname">user's name appears here</span>
712 The example would replace the contents of the <span> tag with the user's
713 realname. If the user's realname was "Bruce" then the resultant output
714 would be "<span>Bruce</span>".
716 tal:attributes="attribute expression; attribute expression; ..."
717 Set attributes on this tag to the results of expressions. For example::
719 <a tal:attributes="href string:user${request/user/id}">My Details</a>
721 In the example, the "href" attribute of the <a> tag is set to the value of
722 the "string:user${request/user/id}" expression, which will be something
723 like "user123".
725 tal:omit-tag="expression"
726 Remove this tag (but not its contents) if the expression is true. For
727 example::
729 <span tal:omit-tag="python:1">Hello, world!</span>
731 would result in output of::
733 Hello, world!
735 Note that the commands on a given tag are evaulated in the order above, so
736 *define* comes before *condition*, and so on.
738 Additionally, a tag is defined, tal:block, which is removed from output. Its
739 content is not, but the tag itself is (so don't go using any tal:attributes
740 commands on it). This is useful for making arbitrary blocks of HTML
741 conditional or repeatable (very handy for repeating multiple table rows,
742 which would othewise require an illegal tag placement to effect the repeat).
744 The expressions you may use in the attibute values may be one of the following
745 three forms:
747 Path Expressions - eg. ``item/status/checklist``
748 These are object attribute / item accesses. Roughly speaking, the path
749 ``item/status/checklist`` is broken into parts ``item``, ``status``
750 and ``checklist``. The ``item`` part is the root of the expression.
751 We then look for a ``status`` attribute on ``item``, or failing that, a
752 ``status`` item (as in ``item['status']``). If that
753 fails, the path expression fails. When we get to the end, the object we're
754 left with is evaluated to get a string - methods are called, objects are
755 stringified. Path expressions may have an optional ``path:`` prefix, though
756 they are the default expression type, so it's not necessary.
758 XXX | components of expressions
760 XXX "nothing" and "default"
762 String Expressions - eg. ``string:hello ${user/name}``
763 These expressions are simple string interpolations (though they can be just
764 plain strings with no interpolation if you want. The expression in the
765 ``${ ... }`` is just a path expression as above.
767 Python Expressions - eg. ``python: 1+1``
768 These expressions give the full power of Python. All the "root level"
769 variables are available, so ``python:item.status.checklist()`` would be
770 equivalent to ``item/status/checklist``, assuming that ``checklist`` is
771 a method.
773 Information available to templates
774 ----------------------------------
776 The following variables are available to templates.
778 .. taken from roundup.cgi.templating.RoundupPageTemplate docstring
780 *context*
781 The current context. This is either None, a wrapper around a
782 hyperdb class (an HTMLClass) or a wrapper around a hyperdb item (an
783 HTMLItem).
784 *request*
785 Includes information about the current request, including:
786 - the url
787 - the current index information (``filterspec``, ``filter`` args,
788 ``properties``, etc) parsed out of the form.
789 - methods for easy filterspec link generation
790 - *user*, the current user item as an HTMLItem instance
791 - *form*
792 The current CGI form information as a mapping of form argument
793 name to value
794 *tracker*
795 The current tracker
796 *db*
797 The current database, through which db.config may be reached.
798 *nothing*
799 This is a special variable - if an expression evaluates to this, then the
800 tag (in the case of a tal:replace), its contents (in the case of
801 tal:content) or some attributes (in the case of tal:attributes) will not
802 appear in the the output. So for example::
804 <span tal:attributes="class nothing">Hello, World!</span>
806 would result in::
808 <span>Hello, World!</span>
810 *default*
811 Also a special variable - if an expression evaluates to this, then the
812 existing HTML in the template will not be replaced or removed, it will
813 remain. So::
815 <span tal:replace="default">Hello, World!</span>
817 would result in::
819 <span>Hello, World!</span>
821 The context variable
822 ~~~~~~~~~~~~~~~~~~~~
824 The *context* variable is one of three things based on the current context
825 (see `determining web context`_ for how we figure this out):
827 1. if we're looking at a "home" page, then it's None
828 2. if we're looking at a specific hyperdb class, it's an HTMLClass instance
829 3. if we're looking at a specific hyperdb item, it's an HTMLItem instance
831 If the context is not None, we can access the properties of the class or item.
832 The only real difference between cases 2 and 3 above are:
834 1. the properties may have a real value behind them, and this will appear if
835 the property is displayed through ``context/property`` or
836 ``context/property/field``.
837 2. the context's "id" property will be a false value in the second case, but
838 a real, or true value in the third. Thus we can determine whether we're
839 looking at a real item from the hyperdb by testing "context/id".
842 The request variable
843 ~~~~~~~~~~~~~~~~~~~~
845 The request variable is packed with information about the current request.
847 .. taken from roundup.cgi.templating.HTMLRequest docstring
849 =========== ================================================================
850 Variable Holds
851 =========== ================================================================
852 form the CGI form as a cgi.FieldStorage
853 env the CGI environment variables
854 url the current URL path for this request
855 base the base URL for this tracker
856 user a HTMLUser instance for this user
857 classname the current classname (possibly None)
858 template the current template (suffix, also possibly None)
859 form the current CGI form variables in a FieldStorage
860 =========== ================================================================
862 **Index page specific variables (indexing arguments)**
864 =========== ================================================================
865 Variable Holds
866 =========== ================================================================
867 columns dictionary of the columns to display in an index page
868 show a convenience access to columns - request/show/colname will
869 be true if the columns should be displayed, false otherwise
870 sort index sort column (direction, column name)
871 group index grouping property (direction, column name)
872 filter properties to filter the index on
873 filterspec values to filter the index on
874 search_text text to perform a full-text search on for an index
875 =========== ================================================================
878 Displaying Properties
879 ---------------------
881 Properties appear in the user interface in three contexts: in indices, in
882 editors, and as search arguments.
883 For each type of property, there are several display possibilities.
884 For example, in an index view, a string property may just be
885 printed as a plain string, but in an editor view, that property may be
886 displayed in an editable field.
889 Index Views
890 -----------
892 This is one of the class context views. It is also the default view for
893 classes. The template used is "*classname*.index".
895 Index View Specifiers
896 ~~~~~~~~~~~~~~~~~~~~~
898 An index view specifier (URL fragment) looks like this (whitespace has been
899 added for clarity)::
901 /issue?status=unread,in-progress,resolved&
902 topic=security,ui&
903 :group=+priority&
904 :sort==activity&
905 :filters=status,topic&
906 :columns=title,status,fixer
908 The index view is determined by two parts of the specifier: the layout part and
909 the filter part. The layout part consists of the query parameters that begin
910 with colons, and it determines the way that the properties of selected items
911 are displayed. The filter part consists of all the other query parameters, and
912 it determines the criteria by which items are selected for display.
913 The filter part is interactively manipulated with the form widgets displayed in
914 the filter section. The layout part is interactively manipulated by clicking on
915 the column headings in the table.
917 The filter part selects the union of the sets of items with values matching any
918 specified Link properties and the intersection of the sets of items with values
919 matching any specified Multilink properties.
921 The example specifies an index of "issue" items. Only items with a "status" of
922 either "unread" or "in-progres" or "resolved" are displayed, and only items
923 with "topic" values including both "security" and "ui" are displayed. The items
924 are grouped by priority, arranged in ascending order; and within groups, sorted
925 by activity, arranged in descending order. The filter section shows filters for
926 the "status" and "topic" properties, and the table includes columns for the
927 "title", "status", and "fixer" properties.
929 Filtering of indexes
930 ~~~~~~~~~~~~~~~~~~~~
932 TODO
934 Searching Views
935 ---------------
937 This is one of the class context views. The template used is typically
938 "*classname*.search".
940 TODO
942 Item Views
943 ----------
945 The basic view of a hyperdb item is provided by the "*classname*.item"
946 template. It generally has three sections; an "editor", a "spool" and a
947 "history" section.
951 Editor Section
952 ~~~~~~~~~~~~~~
954 The editor section is used to manipulate the item - it may be a
955 static display if the user doesn't have permission to edit the item.
957 Here's an example of a basic editor template (this is the default "classic"
958 template issue item edit form - from the "issue.item" template)::
960 <table class="form">
961 <tr>
962 <th nowrap>Title</th>
963 <td colspan=3 tal:content="structure python:context.title.field(size=60)">title</td>
964 </tr>
966 <tr>
967 <th nowrap>Priority</th>
968 <td tal:content="structure context/priority/menu">priority</td>
969 <th nowrap>Status</th>
970 <td tal:content="structure context/status/menu">status</td>
971 </tr>
973 <tr>
974 <th nowrap>Superseder</th>
975 <td>
976 <span tal:replace="structure python:context.superseder.field(showid=1, size=20)" />
977 <span tal:replace="structure python:db.issue.classhelp('id,title', label='list', width=500)" />
978 <span tal:condition="context/superseder">
979 <br>View: <span tal:replace="structure python:context.superseder.link(showid=1)" />
980 </span>
981 </td>
982 <th nowrap>Nosy List</th>
983 <td>
984 <span tal:replace="structure context/nosy/field" />
985 <span tal:replace="structure python:db.user.classhelp('username,realname,address,phone', label='list', width=500)" />
986 </td>
987 </tr>
989 <tr>
990 <th nowrap>Assigned To</th>
991 <td tal:content="structure context/assignedto/menu">
992 assignedto menu
993 </td>
994 <td> </td>
995 <td> </td>
996 </tr>
998 <tr>
999 <th nowrap>Change Note</th>
1000 <td colspan=3>
1001 <textarea name=":note" wrap="hard" rows="5" cols="60"></textarea>
1002 </td>
1003 </tr>
1005 <tr>
1006 <th nowrap>File</th>
1007 <td colspan=3><input type="file" name=":file" size="40"></td>
1008 </tr>
1010 <tr>
1011 <td> </td>
1012 <td colspan=3 tal:content="structure context/submit">
1013 submit button will go here
1014 </td>
1015 </tr>
1016 </table>
1019 When a change is submitted, the system automatically generates a message
1020 describing the changed properties. As shown in the example, the editor
1021 template can use the ":note" and ":file" fields, which are added to the
1022 standard change note message generated by Roundup.
1024 Spool Section
1025 ~~~~~~~~~~~~~
1027 The spool section lists related information like the messages and files of
1028 an issue.
1030 TODO
1033 History Section
1034 ~~~~~~~~~~~~~~~
1036 The final section displayed is the history of the item - its database journal.
1037 This is generally generated with the template::
1039 <tal:block tal:replace="structure context/history" />
1041 *To be done:*
1043 *The actual history entries of the item may be accessed for manual templating
1044 through the "journal" method of the item*::
1046 <tal:block tal:repeat="entry context/journal">
1047 a journal entry
1048 </tal:block>
1050 *where each journal entry is an HTMLJournalEntry.*
1052 Defining new web actions
1053 ------------------------
1055 XXX
1058 Access Controls
1059 ===============
1061 A set of Permissions are built in to the security module by default:
1063 - Edit (everything)
1064 - View (everything)
1066 The default interfaces define:
1068 - Web Registration
1069 - Web Access
1070 - Web Roles
1071 - Email Registration
1072 - Email Access
1074 These are hooked into the default Roles:
1076 - Admin (Edit everything, View everything, Web Roles)
1077 - User (Web Access, Email Access)
1078 - Anonymous (Web Registration, Email Registration)
1080 And finally, the "admin" user gets the "Admin" Role, and the "anonymous" user
1081 gets the "Anonymous" assigned when the database is initialised on installation.
1082 The two default schemas then define:
1084 - Edit issue, View issue (both)
1085 - Edit file, View file (both)
1086 - Edit msg, View msg (both)
1087 - Edit support, View support (extended only)
1089 and assign those Permissions to the "User" Role. New users are assigned the
1090 Roles defined in the config file as:
1092 - NEW_WEB_USER_ROLES
1093 - NEW_EMAIL_USER_ROLES
1095 You may alter the configuration variables to change the Role that new web or
1096 email users get, for example to not give them access to the web interface if
1097 they register through email.
1099 You may use the ``roundup-admin`` "``security``" command to display the
1100 current Role and Permission configuration in your tracker.
1102 Adding a new Permission
1103 -----------------------
1105 When adding a new Permission, you will need to:
1107 1. add it to your tracker's dbinit so it is created
1108 2. enable it for the Roles that should have it (verify with
1109 "``roundup-admin security``")
1110 3. add it to the relevant HTML interface templates
1111 4. add it to the appropriate xxxPermission methods on in your tracker
1112 interfaces module
1116 Examples
1117 ========
1119 Adding a new field to a roundup schema
1120 --------------------------------------
1122 This example shows how to add a new constrained property (ie. a selection of
1123 distinct values) to your tracker.
1125 Introduction
1126 ~~~~~~~~~~~~
1128 To make the classic schema of roundup useful as a todo tracking system
1129 for a group of systems administrators, it needed an extra data field
1130 per issue: a category.
1132 This would let sysads quickly list all todos in their particular
1133 area of interest without having to do complex queries, and without
1134 relying on the spelling capabilities of other sysads (a losing
1135 proposition at best).
1137 Adding a field to the database
1138 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1140 This is the easiest part of the change. The category would just be a plain
1141 string, nothing fancy. To change what is in the database you need to add
1142 some lines to the ``open()`` function in ``dbinit.py``::
1144 category = Class(db, "category", name=String())
1145 category.setkey("name")
1147 Here we are setting up a chunk of the database which we are calling
1148 "category". It contains a string, which we are refering to as "name" for
1149 lack of a more imaginative title. Then we are setting the key of this chunk
1150 of the database to be that "name". This is equivalent to an index for
1151 database types. This also means that there can only be one category with a
1152 given name.
1154 Adding the above lines allows us to create categories, but they're not tied
1155 to the issues that we are going to be creating. It's just a list of categories
1156 off on its own, which isn't much use. We need to link it in with the issues.
1157 To do that, find the lines in the ``open()`` function in ``dbinit.py`` which
1158 set up the "issue" class, and then add a link to the category::
1160 issue = IssueClass(db, "issue", ... , category=Multilink("category"), ... )
1162 The Multilink() means that each issue can have many categories. If you were
1163 adding something with a more one to one relationship use Link() instead.
1165 That is all you need to do to change the schema. The rest of the effort is
1166 fiddling around so you can actually use the new category.
1168 Setting up security on the new objects
1169 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1171 By default only the admin user can look at and change objects. This doesn't
1172 suit us, as we want any user to be able to create new categories as
1173 required, and obviously everyone needs to be able to view the categories of
1174 issues for it to be useful.
1176 We therefore need to change the security of the category objects. This is
1177 also done in the ``open()`` function of ``dbinit.py``.
1179 There are currently two loops which set up permissions and then assign them
1180 to various roles. Simply add the new "category" to both lists::
1182 # new permissions for this schema
1183 for cl in 'issue', 'file', 'msg', 'user', 'category':
1184 db.security.addPermission(name="Edit", klass=cl,
1185 description="User is allowed to edit "+cl)
1186 db.security.addPermission(name="View", klass=cl,
1187 description="User is allowed to access "+cl)
1189 # Assign the access and edit permissions for issue, file and message
1190 # to regular users now
1191 for cl in 'issue', 'file', 'msg', 'category':
1192 p = db.security.getPermission('View', cl)
1193 db.security.addPermissionToRole('User', p)
1194 p = db.security.getPermission('Edit', cl)
1195 db.security.addPermissionToRole('User', p)
1197 So you are in effect doing the following::
1199 db.security.addPermission(name="Edit", klass='category',
1200 description="User is allowed to edit "+'category')
1201 db.security.addPermission(name="View", klass='category',
1202 description="User is allowed to access "+'category')
1204 which is creating two permission types; that of editing and viewing
1205 "category" objects respectively. Then the following lines assign those new
1206 permissions to the "User" role, so that normal users can view and edit
1207 "category" objects::
1209 p = db.security.getPermission('View', 'category')
1210 db.security.addPermissionToRole('User', p)
1212 p = db.security.getPermission('Edit', 'category')
1213 db.security.addPermissionToRole('User', p)
1215 This is all the work that needs to be done for the database. It will store
1216 categories, and let users view and edit them. Now on to the interface
1217 stuff.
1219 Changing the web left hand frame
1220 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1222 We need to give the users the ability to create new categories, and the
1223 place to put the link to this functionality is in the left hand function
1224 bar, under the "Issues" area. The file that defines how this area looks is
1225 ``html/page``, which is what we are going to be editing next.
1227 If you look at this file you can see that it contains a lot of "classblock"
1228 sections which are chunks of HTML that will be included or excluded in the
1229 output depending on whether the condition in the classblock is met. Under
1230 the end of the classblock for issue is where we are going to add the
1231 category code::
1233 <p class="classblock"
1234 tal:condition="python:request.user.hasPermission('View', 'category')">
1235 <b>Categories</b><br>
1236 <a tal:condition="python:request.user.hasPermission('Edit', 'category')"
1237 href="category?:template=item">New Category<br></a>
1238 </p>
1240 The first two lines is the classblock definition, which sets up a condition
1241 that only users who have "View" permission to the "category" object will
1242 have this section included in their output. Next comes a plain "Categories"
1243 header in bold. Everyone who can view categories will get that.
1245 Next comes the link to the editing area of categories. This link will only
1246 appear if the condition is matched: that condition being that the user has
1247 "Edit" permissions for the "category" objects. If they do have permission
1248 then they will get a link to another page which will let the user add new
1249 categories.
1251 Note that if you have permission to view but not edit categories then all
1252 you will see is a "Categories" header with nothing underneath it. This is
1253 obviously not very good interface design, but will do for now. I just claim
1254 that it is so I can add more links in this section later on. However to fix
1255 the problem you could change the condition in the classblock statement, so
1256 that only users with "Edit" permission would see the "Categories" stuff.
1258 Setting up a page to edit categories
1259 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1261 We defined code in the previous section which let users with the
1262 appropriate permissions see a link to a page which would let them edit
1263 conditions. Now we have to write that page.
1265 The link was for the item template for the category object. This translates
1266 into the system looking for a file called ``category.item`` in the ``html``
1267 tracker directory. This is the file that we are going to write now.
1269 First we add an id tag in a comment which doesn't affect the outcome
1270 of the code at all but is essential for managing the changes to this
1271 file. It is useful for debugging however, if you load a page in a
1272 browser and look at the page source, you can see which sections come
1273 from which files by looking for these comments::
1275 <!-- dollarId: category.item,v 1.3 2002/05/22 00:32:34 me Exp dollar-->
1277 Next we need to setup up a standard HTML form, which is the whole
1278 purpose of this file. We link to some handy javascript which sends the form
1279 through only once. This is to stop users hitting the send button
1280 multiple times when they are impatient and thus having the form sent
1281 multiple times::
1283 <form method="POST" onSubmit="return submit_once()"
1284 enctype="multipart/form-data">
1286 Next we define some code which sets up the minimum list of fields that we
1287 require the user to enter. There will be only one field, that of "name", so
1288 they user better put something in it otherwise the whole form is pointless::
1290 <input type="hidden" name=":required" value="name">
1292 To get everything to line up properly we will put everything in a table,
1293 and put a nice big header on it so the user has an idea what is happening::
1295 <table class="form">
1296 <tr class="strong-header"><td colspan=2>Category</td></tr>
1298 Next we need the actual field that the user is going to enter the new
1299 category. The "context.name.field(size=60)" bit tells roundup to generate a
1300 normal HTML field of size 60, and the contents of that field will be the
1301 "name" variable of the current context (which is "category"). The upshot of
1302 this is that when the user types something in to the form, a new category
1303 will be created with that name::
1305 <tr>
1306 <td nowrap>Name</td>
1307 <td tal:content="structure python:context.name.field(size=60)">name</td>
1308 </tr>
1310 Finally a submit button so that the user can submit the new category::
1312 <tr>
1313 <td> </td>
1314 <td colspan=3 tal:content="structure context/submit">
1315 submit button will go here
1316 </td>
1317 </tr>
1319 So putting it all together, and closing the table and form we get::
1321 <!-- dollarId: category.item,v 1.3 2002/05/22 00:32:34 richard Exp dollar-->
1323 <form method="POST" onSubmit="return submit_once()"
1324 enctype="multipart/form-data">
1326 <input type="hidden" name=":required" value="name">
1328 <table class="form">
1329 <tr class="strong-header"><td colspan=2>Category</td></tr>
1331 <tr>
1332 <td nowrap>Name</td>
1333 <td tal:content="structure python:context.name.field(size=60)">name</td>
1334 </tr>
1336 <tr>
1337 <td> </td>
1338 <td colspan=3 tal:content="structure context/submit">
1339 submit button will go here
1340 </td>
1341 </tr>
1342 </table>
1343 </form>
1345 This is quite a lot to just ask the user one simple question, but
1346 there is a lot of setup for basically one line (the form line) to do
1347 its work. To add another field to "category" would involve one more line
1348 (well maybe a few extra to get the formatting correct).
1350 Adding the category to the issue
1351 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1353 We now have the ability to create issues to our hearts content, but
1354 that is pointless unless we can assign categories to issues. Just like
1355 the ``html/category.item`` file was used to define how to add a new
1356 category, the ``html/issue.item`` is used to define how a new issue is
1357 created.
1359 Just like ``category.issue`` this file defines a form which has a table to lay
1360 things out. It doesn't matter where in the table we add new stuff,
1361 it is entirely up to your sense of aesthetics::
1363 <th nowrap>Category</th>
1364 <td><span tal:replace="structure context/category/field" />
1365 <span tal:replace="structure python:db.category.classhelp('name',
1366 label='list', width=500)" />
1367 </td>
1369 First we define a nice header so that the user knows what the next section
1370 is, then the middle line does what we are most interested in. This
1371 ``context/category/field`` gets replaced with a field which contains the
1372 category in the current context (the current context being the new issue).
1374 The classhelp lines generate a link (labelled "list") to a popup window
1375 which contains the list of currently known categories.
1377 Searching on categories
1378 ~~~~~~~~~~~~~~~~~~~~~~~
1380 We can add categories, and create issues with categories. The next obvious
1381 thing that we would like to be would be to search issues based on their
1382 category, so that any one working on the web server could look at all
1383 issues in the category "Web" for example.
1385 If you look in the html/page file and look for the "Search Issues" you will
1386 see that it looks something like ``<a href="issue?:template=search">Search
1387 Issues</a>`` which shows us that when you click on "Search Issues" it will
1388 be looking for a ``issue.search`` file to display. So that is indeed the file
1389 that we are going to change.
1391 If you look at this file it should be starting to seem familiar. It is a
1392 simple HTML form using a table to define structure. You can add the new
1393 category search code anywhere you like within that form::
1395 <tr>
1396 <th>Category:</th>
1397 <td>
1398 <select name="category">
1399 <option value="">don't care</option>
1400 <option value="">------------</option>
1401 <option tal:repeat="s db/category/list" tal:attributes="value s/name"
1402 tal:content="s/name">category to filter on</option>
1403 </select>
1404 </td>
1405 <td><input type="checkbox" name=":columns" value="category" checked></td>
1406 <td><input type="radio" name=":sort" value="category"></td>
1407 <td><input type="radio" name=":group" value="category"></td>
1408 </tr>
1410 Most of this is straightforward to anyone who knows HTML. It is just
1411 setting up a select list followed by a checkbox and a couple of radio
1412 buttons.
1414 The ``tal:repeat`` part repeats the tag for every item in the "category"
1415 table and setting "s" to be each category in turn.
1417 The ``tal:attributes`` part is setting up the ``value=`` part of the option tag
1418 to be the name part of "s" which is the current category in the loop.
1420 The ``tal:content`` part is setting the contents of the option tag to be the
1421 name part of "s" again. For objects more complex than category, obviously
1422 you would put an id in the value, and the descriptive part in the content;
1423 but for category they are the same.
1425 Adding category to the default view
1426 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1428 We can now add categories, add issues with categories, and search issues
1429 based on categories. This is everything that we need to do, however there
1430 is some more icing that we would like. I think the category of an issue is
1431 important enough that it should be displayed by default when listing all
1432 the issues.
1434 Unfortunately, this is a bit less obvious than the previous steps. The code
1435 defining how the issues look is in ``html/issue.index``. This is a large table
1436 with a form down the bottom for redisplaying and so forth.
1438 Firstly we need to add an appropriate header to the start of the table::
1440 <th tal:condition="request/show/category">Category</th>
1442 The condition part of this statement is so that if the user has selected
1443 not to see the Category column then they won't.
1445 The rest of the table is a loop which will go through every issue that
1446 matches the display criteria. The loop variable is "i" - which means that
1447 every issue gets assigned to "i" in turn.
1449 The new part of code to display the category will look like this::
1451 <td tal:condition="request/show/category" tal:content="i/category"></td>
1453 The condition is the same as above: only display the condition when the
1454 user hasn't asked for it to be hidden. The next part is to set the content
1455 of the cell to be the category part of "i" - the current issue.
1457 Finally we have to edit ``html/page`` again. This time to tell it that when the
1458 user clicks on "Unnasigned Issues" or "All Issues" that the category should
1459 be displayed. If you scroll down the page file, you can see the links with
1460 lots of options. The option that we are interested in is the ``:columns=`` one
1461 which tells roundup which fields of the issue to display. Simply add
1462 "category" to that list and it all should work.
1465 Adding in state transition control
1466 ----------------------------------
1468 Sometimes tracker admins want to control the states that users may move issues
1469 to.
1471 1. add a Multilink property to the status class::
1473 stat = Class(db, "status", ... , transitions=Multilink('status'), ...)
1475 and then edit the statuses already created through the web using the
1476 generic class list / CSV editor.
1478 2. add an auditor module ``checktransition.py`` in your tracker's
1479 ``detectors`` directory::
1481 def checktransition(db, cl, nodeid, newvalues):
1482 ''' Check that the desired transition is valid for the "status"
1483 property.
1484 '''
1485 if not newvalues.has_key('status'):
1486 return
1487 current = cl.get(nodeid, 'status')
1488 new = newvalues['status']
1489 if new == current:
1490 return
1491 ok = db.status.get(current, 'transitions')
1492 if new not in ok:
1493 raise ValueError, 'Status not allowed to move from "%s" to "%s"'%(
1494 db.status.get(current, 'name'), db.status.get(new, 'name'))
1496 def init(db):
1497 db.issue.audit('set', checktransition)
1499 3. in the ``issue.item`` template, change the status editing bit from::
1501 <th nowrap>Status</th>
1502 <td tal:content="structure context/status/menu">status</td>
1504 to::
1506 <th nowrap>Status</th>
1507 <td>
1508 <select tal:condition="context/id" name="status">
1509 <tal:block tal:define="ok context/status/transitions"
1510 tal:repeat="state db/status/list">
1511 <option tal:condition="python:state.id in ok"
1512 tal:attributes="value state/id;
1513 selected python:state.id == context.status.id"
1514 tal:content="state/name"></option>
1515 </tal:block>
1516 </select>
1517 <tal:block tal:condition="not:context/id"
1518 tal:replace="structure context/status/menu" />
1519 </td>
1521 which displays only the allowed status to transition to.
1524 -------------------
1526 Back to `Table of Contents`_
1528 .. _`Table of Contents`: index.html