wiki:FlexibleAssignToPlugin

Version 3 (modified by gt4329b, 7 years ago) (diff)

--

What is it?

FlexibleAssignTo finally gives long-suffering Trac admins a way to easily customize the 'assign to' field on tickets. It provides several base classes for you to override and implement your own methods for providing lists of valid users -- you can even customize valid users for each state in your workflow.

Key features:

  • adds new Extension point, IValidOwnerProvider, for plugging in your own components
  • provides SimpleUser base class and helper methods (getlist, getbool) to streamline implementation of your IValidOwnerProvider component(s)
  • data-source agnostic -- FlexibleAssignTo abstracts the nastiness of building a customized 'assign to' select box. All your custom code has to do is decide what users are valid for a particular state and then return them.
  • optional 'ensure_user_data' capability so that users who appear as valid 'assign to' targets get their key data (username, fullname, email) stored in the Trac session_attribute table. The motivation for this was so notification emails could be sent to these users even if they've never logged in and set their preferences.
  • optional get_known_users() replacement that changes Trac's 'known users' concept such that users' name & email data is retrieved from the session_attribute table (designed to work in concert with the 'ensure_user_data' capability).
  • FlexibleAssignTo processing can be selectively disabled for individual workflow states
  • Example plugin implementation included (SampleValidOwnerProvider.py)

Installation

How do I install it?

Just like any other Trac (0.11) plugin -- see step 1 in the 'How do I use it' section below for details.
Note that by itself, this plugin won't make any visible changes to your Trac instance.

Prerequisites

  • Trac 0.11+ (built and tested against 0.11dev trunk r6047)
  • Python 2.5+ (I can't confirm that Python 2.5 is actually required -- but it's the version I developed under and the only one I've tested with. If you successfully use this plugin with another version of Python, please update this wiki with your notes. - Morris)

How do I use it?

1. Install FlexibleAssignTo plugin

To get started, install the base FlexibleAssignTo plugin. Build the .egg file following the plugin packaging instructions here. If you already have setuptools (v0.6+) installed, your command is

python setup.py bdist_egg

Once you've built the .egg, copy it into your Trac environment's plugin directory. You still need to activate the plugin -- in trac.ini:

[components]
flexibleassignto.* = enabled

NOTE: the plugin by itself doesn't do anything -- you have to write your own plugin/component that implements IValidOwnerProvider (step 3 below).

2. Try out the demo

Once you've installed the base FlexibleAssignTo plugin, copy the SampleValidOwnerProvider.py file from the install package into your Trac environment's plugin directory (alongside the FlexibleAssignTo .egg). Restart your server and note the new (bogus) entries in your 'assign to' dropdowns.

3. Create your IValidOwnerProvider component

  1. Create a .py file in your Trac environment's plugins directory -- this module is where you'll write your own class that implements the IValidOwnerProvider Extension point provided by FlexibleAssignTo. This is where your custom logic goes for deciding what users should appear as valid 'assign to' targets for each state -- whether that logic involves querying a database, an LDAP directory, or getting input from your custom array of highly trained homing pigeons. See the SampleValidOwnerProvider.py module included with this plugin for a simple example on how it works.
  2. IValidOwnerProvider component requirements If you want to just jump right in, then all you really need to know is the following:
    • The class should declare that it implements IValidOwnerProvider
    • The class should provide a getUsers method that takes a 'next_action_obj' as it's sole param and returns a list of instances of SimpleUser (or a subclass) representing valid owners of that next state. If this sounds confusing, just look at the getUsers() method in SampleValidOwnerProvider.py

Bugs/Feature Requests

Existing bugs and feature requests for FlexibleAssignToPlugin are here.

If you have any issues, create a new ticket.

Download

Download the zipped source from here.

Source

You can check out FlexibleAssignToPlugin from here using Subversion, or browse the source with Trac.

Example

See the 'How to install section' above for details. For an example of how to implement IValidOwnerProvider, see the included sample plugin SampleValidOwnerProvider.py.

Recent Changes

[10083] by gt4329b on 2011-04-14 20:33:48
[10067] by gt4329b on 2011-04-11 16:12:41
  • updated version to 0.7.13
[10066] by gt4329b on 2011-04-11 16:01:42

fixes #3494 (http://trac-hacks.org/ticket/3494)

  • updated flexibleassignto.py core to work properly with 0.11release+ versions of Trac (thanks chris!)
  • updated AUTHORS to note contribution from chris on #3494
  • updated README version compatibility notes

Author/Contributors

Author: rfmorris (aka gt4329b)
Contributors:

Attachments (3)

Download all attachments as: .zip