Eclipse, Mylyn and Trac 0.11

My first post for ages! Sorry about that....

Something quite exciting, that I've had a crack at fixing myself, but the combination of my poor java and python skills has prevented me from completing this adequately. However, the combined skills of the trac developers and the development team for Mylyn and the Mylyn Trac connector have managed to combine to finally provide the highly awaited Mylyn, Eclipse and custom Trac workflow integration!

[More]

Blog Round #5

 

This week I wrote the round-up in ScribeFire and posted up to Mango Blog.  Only flaw in the plan is I have to remember to manually add an excerpt to the top of the round-up and double check the categories.  (I just noticed that ScribeFire/MangoBlog some how dropped some of my selected categories)

This weeks round-up has ended up with 3 distinct threads, Source Control and all that goodness, ColdFusion frameworks and Open Bluedragon updates.

So lets crack on...

Subversion Branching Preso Online
Sean Corfield has posted his SVN Branching presentation from A Wee Dram.  I didn't make it down for the one day event and would have liked to have seen this presentation, but having read through Sean's presentation it looks like I work with svn the same way as Sean anyway!  Alway nice to know you aren't completely insane! ;)

While I'm adding an svn related link - here's another Terry Ryan has created an unfuddlecfc to help with backing up their svn hosting at unfuddle.com

Also, if you're hosting your own SVN/Trac installations and you're using TOCMacro on your trac environment you need to upgrade this plugin. Take a look here for why : Trac sporadic hang solved

Well this round-up seems to be taking a bit of a source control and ticketing theme to it, so here's another related post! Ray Camden has released a much updated Lighthouse Pro 2.5

Moving on from source control and bug tracking - Congrats to Mark Mandel for his first post on Adobe Devnet with his An Introduction to ColdFusion frameworks article. Even if you know what CF frameworks are out there, this provides a neat summary of the general features and design patterns behind each of them, as well as helping provide a clear distinction between MVC frameworks, dependancy injection and data persistence. 

For more information on frameworks, while Sean Corfield was over in the UK for A Wee Dram he also gave a "Design Patterns" presentation at the Devon CFUG and Tom Chiverton will be presenting on ColdSpring for the ColdFusion Meetup Group on the 16th of October.
It would seem that  my round up this week has some very definite threads!  The next blog post of interest is also on ColdSpring! Scott Stroz has a interesting post on using Coldspring Interceptors with Remote Proxies.

Moving away from frameworks, Matt Woodward has posted a couple of updates on what has been going on with Open Bluedragon. Lots going on with Open BlueDragon and Digging Deeper into the Java Underpinnings of Open Bluedragon

And finally, to end on a humours note - take a look at a slice of life at Alagad and Andy Jarrett's Friday Joke.

Upgrade TOCMacro on Trac 0.11 required

Just a quick post....

I was scanning the Trac User's mailing list this morning and noticed a post by osimon (Simon) from CodeResorts.

It would appear that a bug in the popular TOCMacro can cause sporadic hangs on Trac.  The good news : he's fixed it!
If you use TOCMacro on your trac setup It is definitely recommended that you upgrade (easy_install http://trac-hacks.org/svn/tocmacro/0.11)

Trac 0.11: Creating your own permissions

To add permissions to Trac 0.11 you simply need to add a myPermissions.py file to your Trac environment plugin folder that looks like this:

 

Add your set of permissions to the return command in place of 'MY_FIRST_PERM', 'MY_SECOND_PERM', restart apache and you should be away.

You can now use these permission in your work flow against actionname.permissions entries.

NOTE: you don't need to call the file "myPermissions.py" - its just needs to be a python file with a name of your choosing.

Trac 0.11: Building your own custom workflow

So after much procrastination and Christmas food and presents I've finally got around to writing about custom workflows in Trac 0.11.
Previously, I talked about the workflow-parser and the ini files in the contrib/workflow folder. Hopefully, you'll have had a chance to grab these and have a look at them and generate some of the diagrams using GraphVis.
Now I'm going to have a look at the contents of an ini file and talking about how you build your own workflow.I guess the first thing to mention is that trac workflows are build around actions and moving from one state to another, rather than around states and the actions that can be performed in that state. For instance, you want to assign a new ticket to someone. The action is "assign" the states are "new" and "assigned". The workflow for this action would be:

assign = new -> assigned

Say you also have a "deferred" state and you want to assign that ticket to someone, this workflow entry would become:

assign = new,deferred -> assigned

This forms the basis of building your workflows. There are two states that have hard-coded functionality within trac. These are "new" and "closed" - All new tickets are given a status of "new" when its first created and all tickets need a "closed" state to show tickets as closed in reports. All other states are assumed to be "active".
An action that is worth a mention now is "leave", that will also lead me into action operations. "leave" is a useful action to have. It allows you to add comments, attachments etc. to a ticket without actually changing the state of a ticket.

view plain print about
1leave = * -&gt; *<br />
2leave.operations = leave_status<br />
3leave.default = 1<br />

The operations attribute means is that all states are able to leave the status of a ticket unchanged when saving any changes to a ticket.
You'll notice that the leave action above has an operations and a default attribute added to it. There are actually a few more attributes that you can add to an action. These are:

  • name
  • default
  • operations
  • permissions

The "name" attribute allows you to specify a english name for for action, so if you have an action called say "resolve_accepted", then you can use "resolve_accepted.name = resolve" to make "resolve" be the text that is actually displayed for the action in Trac.
The "default" attribute allows you to specify the order in which actions are displayed in Trac. If not specified, "default" is set to 0 (zero).
The "operations" attribute allows you to specify an operation that will be allowed or performed when this action is taken.
The available operations are: (Taken from the trac wiki)

  • del_owner -- Clear the owner field.
  • set_owner -- Sets the owner to the selected or entered owner.
    • actionname.set_owner may optionally be set to a comma delimited list or a single value.
  • set_owner_to_self -- Sets the owner to the logged in user.
  • del_resolution -- Clears the resolution field
  • set_resolution -- Sets the resolution to the selected value.
    • actionname.set_resolution may optionally be set to a comma delimited list or a single value.
      view plain print about
      1Example:
      2resolve_new = new -&gt; closed<br />
      3resolve_new.name = resolve<br />
      4resolve_new.operations = set_resolution<br />
      5resolve_new.permissions = TICKET_MODIFY<br />
      6resolve_new.set_resolution = invalid,wontfix<br />
  • leave_status -- Displays "leave as <current status>" and makes no change to the ticket.

The "permissions" attribute is a comma delimited list of permissions that are required to perform that action. The example above shows the "resolve" action needing the trac permission "TICKET_MODIFY" for a user to be able to perform this action. NOTE: Permissions must be in UPPERCASE.
So lets put that all together into a very simple workflow.

view plain print about
1leave = * -&gt; *<br />
2leave.operations = leave_status<br />
3leave.default = 1<br />
4accept = new,accepted -&gt; accepted<br />
5accept.permissions = TICKET_MODIFY<br />
6accept.operations = set_owner_to_self<br />
7resolve = new,accepted -&gt; closed<br />
8resolve.permissions = TICKET_MODIFY<br />
9resolve.operations = set_resolution<br />
Hopefully that should give you the basis to build your own more complex workflows.
I've attached a more complex workflow for you to download that including a QA phase, as well as a "defer" and "more info required" route, which looks like this: QA Workflow Image Just as a final note; I mentioned in an entry about Mylyn that Mylyn doesn't seem to show up the custom workflow actions correctly. I haven't had a chance to investigate this properly, but it may be that you need to specify the action.set_resolution explicitly for them to work correctly. As I say though, I haven't had a chance to investigate this properly yet. Some time soon I hope.

Trac 0,11 Custom Workflows - Getting started and testing your workflow.

I've been meaning to write this up for a while, but just don't seem to get around to it.

Custom workflows in Trac 0.11 are probably the coolest new feature in it. That and the supremely easy install and upgrade facilities via the python setuptools, easy_install command. Trac 0.11 Install Whilst I do love how easy installing trac has become that even Big Mad Kev can install it ;oD, this isn't about configuring trac with apache and svn. You can find that out from Andy Allan's posts, as well as my own "svn for idiots" post and from the Edgewall wiki, so I'll shut up and crack on.To build your own trac workflows you are going need a few things.
Firstly, you're going to need to have Python and Trac installed.
Secondly, I highly recommend installing GraphVis
Lastly, you will at least need the contrib/workflow folder out of the trac svn trunk folder.

Starting with the last of these; why do you need this? and how do I get it?
The why is because there are some example workflows and a couple of utilities.
The how is from the command line like this :

view plain print about
1svn export http://svn.edgewall.org/repos/trac/trunk/contrib/workflow/ workflow
This will export the workflow folder from the trac repo into a folder called "workflow" under the folder you are currently in.
You need to have subversion installed to run this command line or you can simply point subclipse or subversive in eclipse at the trac repository and pull the folder into eclipse.

One of the utilities is "showworkflow". This is a handy utility is you're on *nix as it will generate a graphical representation of your workflow in a PDF. This requires that you have graphviz, that I mention above, installed.
If you're on windows, don't worry. The other utility in the contrib folder is a python script called workflow_parser.py. This utility is the reason why I say you need Python and Trac installed. Running this script against your workflow will generate a file that you can give to graphviz, which will then generate a visual representation of your workflow in any number of file types.
This script, unfortunately, isn't standalone and does import a couple of elements from your trac installation, so you will need python and trac available to run it.

Here's how to call the workflow parser:

view plain print about
1python workflow_parser.py simple-workflow.ini > simple-workflow.dot
You need to pass in the ini file and pipe the output to a file. By default workflow_parser.py streams the file to the console.

Having installed GraphViz, you'll find a three utilities available to you; dot, neato and twopi. They all seem to me to give pretty much the same output, but dot seems to give the clearest layout. Open up dot and you'll get a utility that looks like this.

GraphViz dot utilty

You don't have to do a lot with this. In the input file box, browse to the dot file you created from your workflow ini file. In the output file box put the name and path of where you want your visualisation to be saved. Select the output file type you want - I tend to use jpg, png or gif depending on which way the wind is blowing on the day.

Having set up the input, output and the type of output, click on "do layout" and hey presto your output file will be created. Here's one I made earlier using the example simple-workflow.ini

Generated Simple work visualisation

These visualisations help greatly to see exactly what the paths through your workflow are going to be and is invaluable with testing the ini file, as the workflow_parser will throw and error if there is something wrong

Ok - So I feel like that's quite enough for one blog entry, before it gets to be TLDR. I'll write another entry shorly about actually creating and editing workflows.

In the meantime, take a look at the contents of the example ini files in the contrib/workflow folder, generate the diagrams for them and you might also want to take a bit of a look at http://trac.edgewall.org/wiki/TracWorkflow

Trac 0.11 and Mylyn.

I keep hearing various people espousing the joys of task management with Mylyn in Eclipse, so last week I thought I would take a look.Mylyn is easy to install. Just go into Eclipse's Help > Software Updates > Find and Install > Search for new features and add the Mylyn update server. You can find the details of the update server from the Eclipse Wiki When you're given a list of items to install make sure you include the option for the Trac Connector. A quick restart of Eclipse and you're ready to use Mylyn locally and in theory you should be able to add a task respository. If you're on a released version of Trac eg. 0.10.4 you should be able to simply create a repository that points at your Trac installation URL and away you go... With 0.11 Mylyn can't see trac as a valid repository. At this point I kept finding notes saying that you can't use Mylyn with Trac 0.11. I'd also noted from the Mylyn User Guide (link above) that I should be able to use an XML-RPC plugin, but look at this also seemed to suggest that there were problems and the examples look scary. Its actually very simple to set up, the examples are for the API if you want to build your own XML-RPC interfaces and it definately does work! If you've installed Trac 0.11, you should have installed the Python setuptools, so installing the XML-RPC plugin is really easy!

easy_install http://trac-hacks.org/svn/xmlrpcplugin/trunk/

One thing to note - I used the trunk version of the plugin. The tagged version 0.10 doesn't work with Trac 0.11 Restart apache and thats it... What you'll need to do now is go into the plugin admin in trac web admin for the project you want to use as a task repository. You'll need to enable the following components in the tracxmlrpc plugin:

  • XMLRPCSystem
  • All the component with ".ticket" in the module name
  • XMLRPCWeb

Give Apache a quick restart. Now when you setup a task repository in Mylyn in Eclipse, make sure you chose "XML-RPC Plugin (rev. 1950)" as the Access Type under Additional Settings. With a valid user name to access your repo, you're now ready to start building queries in the task list. I really like the interface that Mylyn gives you in eclipse. Now I need to play with all the extra options you get for planning and adding context. Only two bothers I've noticed so far:

  1. I tried to add my queries into folders, but no matter how much I try they all just end up in the top level.
  2. As I wrote this I noticed that actions in our custom workflow aren't showing up

UPDATE : As Don has noted below - to enable the components in the XMLRPC plug-in I recommend using the web admin. This is one of the other superb features of Trac 0.11 - webadmin built in already. No need to have to learn about plug-in when you're first starting with Trac. ;)