Monatsarchiv für December 2011

 
 

Trac Plugins

To use egg based plugins in Trac, you need to have setuptools (version 0.6) installed.

To install setuptools, download the bootstrap module ez_setup.py and execute it as follows:

$ python ez_setup.py

If the ez_setup.py script fails to install the setuptools release, you can download it from PyPI and install it manually.

Plugins can also consist of a single .py file dropped into either the environment or global plugins directory.

Installing a Trac Plugin

For a Single Project

Plugins are packaged as Python eggs. That means they are ZIP archives with the file extension .egg.

If you have downloaded a source distribution of a plugin, and want to build the .egg file, follow this instruction:

  • Unpack the source. It should provide a setup.py.
  • Run:
    $ python setup.py bdist_egg

Then you will have a *.egg file. Examine the output of running python to find where this was created.

Once you have the plugin archive, you need to copy it into the plugins directory of the project environment. Also, make sure that the web server has sufficient permissions to read the plugin egg.

To uninstall a plugin installed this way, remove the egg from plugins directory and restart web server.

Note that the Python version that the egg is built with must
match the Python version with which Trac is run. If for
instance you are running Trac under Python 2.3, but have
upgraded your standalone Python to 2.4, the eggs won’t be
recognized.

Note also that in a multi-project setup, a pool of Python interpreter instances will be dynamically allocated to projects based on need, and since plugins occupy a place in Python’s module system, the first version of any given plugin to be loaded will be used for all the projects. In other words, you cannot use different versions of a single plugin in two projects of a multi-project setup. It may be safer to install plugins for all projects (see below) and then enable them selectively on a project-by-project basis.

For All Projects

With an .egg file

Some plugins (such as SpamFilter) are downloadable as a .egg file which can be installed with the easy_install program:

easy_install TracSpamFilter

If easy_install is not on your system see the Requirements section above to install it. Windows users will need to add the Scripts directory of their Python installation (for example, C:\Python23\Scripts) to their PATH environment variable (see easy_install Windows notes for more information).

If Trac reports permission errors after installing a zipped egg and you would rather not bother providing a egg cache directory writable by the web server, you can get around it by simply unzipping the egg. Just pass --always-unzip to easy_install:

easy_install --always-unzip TracSpamFilter-0.2.1dev_r5943-py2.4.egg

You should end up with a directory having the same name as the zipped egg (complete with .egg extension) and containing its uncompressed contents.

Trac also searches for globally installed plugins.

From source

easy_install makes installing from source a snap. Just give it the URL to either a Subversion repository or a tarball/zip of the source:

easy_install http://svn.edgewall.com/repos/trac/sandbox/spam-filter

Enabling the plugin

Unlike plugins installed per-environment, you’ll have to explicitly enable globally installed plugins via trac.ini. This also applies to plugins installed in the path specified in the [inherit] plugins_dir configuration option. This is done in the [components] section of the configuration file, for example:

[components]
tracspamfilter.* = enabled

The name of the option is the Python package of the plugin. This should be specified in the documentation of the plugin, but can also be easily discovered by looking at the source (look for a top-level directory that contains a file named __init__.py.)

Note: After installing the plugin, you need to restart your web server.

Uninstalling

easy_install or python setup.py does not have an uninstall feature. Hower, it is usually quite trivial to remove a globally installed egg and reference:

  1. Do easy_install -m [plugin name] to remove references from $PYTHONLIB/site-packages/easy-install.pth when the plugin installed by setuptools.
  2. Delete executables from /usr/bin, /usr/local/bin or C:\\Python*\Scripts. For search what executables are there, you may refer to [console-script] section of setup.py.
  3. Delete the .egg file or folder from where it is installed, usually inside $PYTHONLIB/site-packages/.
  4. Restart web server.

If you are uncertain about the location of the egg, here is a small tip to help locate an egg (or any package) – replace myplugin with whatever namespace the plugin uses (as used when enabling the plugin):

>>> import myplugin
>>> print myplugin.__file__
/opt/local/python24/lib/site-packages/myplugin-0.4.2-py2.4.egg/myplugin/__init__.pyc

Setting up the Plugin Cache

Some plugins will need to be extracted by the Python eggs runtime (pkg_resources), so that their contents are actual files on the file system. The directory in which they are extracted defaults to ‘.python-eggs’ in the home directory of the current user, which may or may not be a problem. You can however override the default location using the PYTHON_EGG_CACHE environment variable.

To do this from the Apache configuration, use the SetEnv directive as follows:

SetEnv PYTHON_EGG_CACHE /path/to/dir

This works whether you are using the CGI or the mod_python front-end. Put this directive next to where you set the path to the Trac environment, i.e. in the same <Location> block.

For example (for CGI):

 <Location /trac>
   SetEnv TRAC_ENV /path/to/projenv
   SetEnv PYTHON_EGG_CACHE /path/to/dir
 </Location>

or (for mod_python):

 <Location /trac>
   SetHandler mod_python
   ...
   SetEnv PYTHON_EGG_CACHE /path/to/dir
 </Location>

Note: SetEnv requires the mod_env module which needs to be activated for Apache. In this case the SetEnv directive can also be used in the mod_python Location block.

For FastCGI, you’ll need to -initial-env option, or whatever is provided by your web server for setting environment variables.

Note: that if you already use -initial-env to set the project directory for either a single project or parent you will need to add an additional -initial-env directive to the FastCgiConfig directive. I.e.

FastCgiConfig -initial-env TRAC_ENV=/var/lib/trac -initial-env PYTHON_EGG_CACHE=/var/lib/trac/plugin-cache

About hook scripts

If you have set up some subversion hook scripts that call the Trac engine – such as the post-commit hook script provided in the /contrib directory – make sure you define the PYTHON_EGG_CACHE environment variable within these scripts as well.

Troubleshooting

Is setuptools properly installed?

Try this from the command line:

$ python -c "import pkg_resources"

If you get no output, setuptools is installed. Otherwise, you’ll need to install it before plugins will work in Trac.

Did you get the correct version of the Python egg?

Python eggs have the Python version encoded in their filename. For example, MyPlugin-1.0-py2.4.egg is an egg for Python 2.4, and will not be loaded if you’re running a different Python version (such as 2.3 or 2.5).

Also, verify that the egg file you downloaded is indeed a ZIP archive. If you downloaded it from a Trac site, chances are you downloaded the HTML preview page instead.

Is the plugin enabled?

If you install a plugin globally (i.e. not inside the plugins directory of the Trac project environment) you will have to explicitly enable it in trac.ini. Make sure that:

    • you actually added the necessary line(s) to the [components] section
    • the package/module names are correct

li>the value is “enabled”, not e.g. “enable”

Check the permissions on the egg file

Trac must be able to read the file.

Check the log files

Enable logging and set the log level to DEBUG, then watch the log file for messages about loading plugins.

Verify you have proper permissions

Some plugins require you have special permissions in order to use them. WebAdmin, for example, requires the user to have TRAC_ADMIN permissions for it to show up on the navigation bar.

Is the wrong version of the plugin loading?

If you put your plugins inside plugins directories, and certainly if you have more than one project, you need to make sure that the correct version of the plugin is loading. Here are some basic rules:

  • Only one version of the plugin can be loaded for each running Trac server (ie. each Python process). The Python namespaces and module list will be shared, and it cannot handle duplicates. Whether a plugin is enabled or disabled makes no difference.
  • A globally installed plugin (typically setup.py install) will override any version in global or project plugins directories. A plugin from the global plugins directory will be located before any project plugins directory.
  • If your Trac server hosts more than one project (as with TRAC_ENV_PARENT_DIR setups), then having two versions of a plugin in two different projects will give uncertain results. Only one of them will load, and the one loaded will be shared by both projects. Trac will load the first found – basically from the project that receives the first request.
  • Having more than one version listed inside Python site-packages is fine (ie. installed with setup.py install) – setuptools will make sure you get the version installed most recently. However, don’t store more than one version inside a global or project plugins directory – neither version number nor installed date will matter at all. There is no way to determine which one will be located first when Trac searches the directory for plugins.

If all of the above failed

OK, so the logs don’t mention plugins, the egg is readable, the python version is correct and the egg has been installed globally (and is enabled in the trac.ini) and it still doesn’t work or give any error messages or any other indication as to why? Hop on the IrcChannel and ask away.

Trac Flow Work

Environments upgraded from 0.10

When you run trac-admin <env> upgrade, your trac.ini will be modified to include a [ticket-workflow] section.
The workflow configured in this case is the original workflow, so that ticket actions will behave like they did in 0.10.

There are some significant “warts” in this; such as accepting a ticket sets it to ‘assigned’ state, and assigning a ticket sets it to ‘new’ state. Perfectly obvious, right?
So you will probably want to migrate to “basic” workflow; contrib/workflow/migrate_original_to_basic.py may be helpful.

Environments created with 0.11

When a new environment is created, a default workflow is configured in your trac.ini. This workflow is the basic workflow (described in basic-workflow.ini), which is somewhat different from the workflow of the 0.10 releases.

Additional Ticket Workflows

There are several example workflows provided in the Trac source tree; look in contrib/workflow for .ini config sections. One of those may be a good match for what you want. They can be pasted into the [ticket-workflow] section of your trac.ini file.

Here are some diagrams of the above examples.

Basic Ticket Workflow Customization

Note: Ticket “statuses” or “states” are not separately defined. The states a ticket can be in are automatically generated by the transitions defined in a workflow. Therefore, creating a new ticket state simply requires defining a state transition in the workflow that starts or ends with that state.

Create a [ticket-workflow] section in trac.ini.
Within this section, each entry is an action that may be taken on a ticket.
For example, consider the accept action from simple-workflow.ini:

accept = new,accepted -> accepted
accept.permissions = TICKET_MODIFY
accept.operations = set_owner_to_self

The first line in this example defines the accept action, along with the states the action is valid in (new and accepted), and the new state of the ticket when the action is taken (accepted).
The accept.permissions line specifies what permissions the user must have to use this action.
The accept.operations line specifies changes that will be made to the ticket in addition to the status change when this action is taken. In this case, when a user clicks on accept, the ticket owner field is updated to the logged in user. Multiple operations may be specified in a comma separated list.

The available operations are:

  • 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_resolutionmay optionally be set to a comma delimited list or a single value.
      Example:
      
      resolve_new = new -> closed
      resolve_new.name = resolve
      resolve_new.operations = set_resolution
      resolve_new.permissions = TICKET_MODIFY
      resolve_new.set_resolution = invalid,wontfix
  • leave_status — Displays “leave as <current status>” and makes no change to the ticket.

Note: Specifying conflicting operations (such as set_owner and del_owner) has unspecified results.

resolve_accepted = accepted -> closed
resolve_accepted.name = resolve
resolve_accepted.permissions = TICKET_MODIFY
resolve_accepted.operations = set_resolution

In this example, we see the .name attribute used. The action here is resolve_accepted, but it will be presented to the user as resolve.

For actions that should be available in all states, * may be used in place of the state. The obvious example is the leave action:

leave = * -> *
leave.operations = leave_status
leave.default = 1

This also shows the use of the .default attribute. This value is expected to be an integer, and the order in which the actions are displayed is determined by this value. The action with the highest .default value is listed first, and is selected by default. The rest of the actions are listed in order of decreasing .default values.
If not specified for an action, .default is 0. The value may be negative.

There are a couple of hard-coded constraints to the workflow. In particular, tickets are created with status new, and tickets are expected to have a closed state. Further, the default reports/queries treat any state other than closed as an open state.

While creating or modifying a ticket workfow, contrib/workflow/workflow_parser.py may be useful. It can create .dot files that GraphViz understands to provide a visual description of the workflow.

This can be done as follows (your install path may be different).

cd /var/local/trac_devel/contrib/workflow/
sudo ./showworkflow /srv/trac/PlannerSuite/conf/trac.ini

And then open up the resulting trac.pdf file created by the script (it will be in the same directory as the trac.ini file).

After you have changed a workflow, you need to restart apache for the changes to take effect. This is important, because the changes will still show up when you run your script, but all the old workflow steps will still be there until the server is restarted.

Example: Adding optional Testing with Workflow

By adding the following to your [ticket-workflow] section of trac.ini you get optional testing. When the ticket is in new, accepted or needs_work status you can choose to submit it for testing. When it’s in the testing status the user gets the option to reject it and send it back to needs_work, or pass the testing and send it along to closed. If they accept it then it gets automatically marked as closed and the resolution is set to fixed. Since all the old work flow remains, a ticket can skip this entire section.

testing = new,accepted,needs_work,assigned,reopened -> testing
testing.name = Submit to reporter for testing
testing.permissions = TICKET_MODIFY

reject = testing -> needs_work
reject.name = Failed testing, return to developer

pass = testing -> closed
pass.name = Passes Testing
pass.operations = set_resolution
pass.set_resolution = fixed

Example: Add simple optional generic review state

Sometimes Trac is used in situations where “testing” can mean different things to different people so you may want to create an optional workflow state that is between the default workflow’s assigned and closed states, but does not impose implementation-specific details. The only new state you need to add for this is a reviewing state. A ticket may then be “submitted for review” from any state that it can be reassigned. If a review passes, you can re-use the resolve action to close the ticket, and if it fails you can re-use the reassign action to push it back into the normal workflow.

The new reviewing state along with its associated review action looks like this:

review = new,assigned,reopened -> reviewing
review.operations = set_owner
review.permissions = TICKET_MODIFY

Then, to integrate this with the default Trac 0.11 workflow, you also need to add the reviewing state to the accept and resolve actions, like so:

accept = new,reviewing -> assigned
[…]
resolve = new,assigned,reopened,reviewing -> closed

Optionally, you can also add a new action that allows you to change the ticket’s owner without moving the ticket out of the reviewing state. This enables you to reassign review work without pushing the ticket back to the new status.

reassign_reviewing = reviewing -> *
reassign_reviewing.name = reassign review
reassign_reviewing.operations = set_owner
reassign_reviewing.permissions = TICKET_MODIFY

The full [ticket-workflow] configuration will thus look like this:

[ticket-workflow]
accept = new,reviewing -> assigned
accept.operations = set_owner_to_self
accept.permissions = TICKET_MODIFY
leave = * -> *
leave.default = 1
leave.operations = leave_status
reassign = new,assigned,reopened -> new
reassign.operations = set_owner
reassign.permissions = TICKET_MODIFY
reopen = closed -> reopened
reopen.operations = del_resolution
reopen.permissions = TICKET_CREATE
resolve = new,assigned,reopened,reviewing -> closed
resolve.operations = set_resolution
resolve.permissions = TICKET_MODIFY
review = new,assigned,reopened -> reviewing
review.operations = set_owner
review.permissions = TICKET_MODIFY
reassign_reviewing = reviewing -> *
reassign_reviewing.operations = set_owner
reassign_reviewing.name = reassign review
reassign_reviewing.permissions = TICKET_MODIFY

Example: Limit the resolution options for a new ticket

The above resolve_new operation allows you to set the possible resolutions for a new ticket. By modifying the existing resolve action and removing the new status from before the -> we then get two resolve actions. One with limited resolutions for new tickets, and then the regular one once a ticket is accepted.

resolve_new = new -> closed
resolve_new.name = resolve
resolve_new.operations = set_resolution
resolve_new.permissions = TICKET_MODIFY
resolve_new.set_resolution = invalid,wontfix,duplicate

resolve = assigned,accepted,reopened -> closed
resolve.operations = set_resolution
resolve.permissions = TICKET_MODIFY

Advanced Ticket Workflow Customization

If the customization above is not extensive enough for your needs, you can extend the workflow using plugins. These plugins can provide additional operations for the workflow (like code_review), or implement side-effects for an action (such as triggering a build) that may not be merely simple state changes. Look at sample-plugins/workflow for a few simple examples to get started.

But if even that is not enough, you can disable the ConfigurableTicketWorkflow component and create a plugin that completely replaces it.

Adding Workflow States to Milestone Progress Bars

If you add additional states to your workflow, you may want to customize your milestone progress bars as well. See TracIni.

some ideas for next steps

New enhancement ideas for the workflow system should be filed as enhancement tickets against the ticket system component. If desired, add a single-line link to that ticket here. Also look at the [th:wiki:AdvancedTicketWorkflowPlugin] as it provides experimental operations.

If you have a response to the comments below, create an enhancement ticket, and replace the description below with a link to the ticket.

  • the “operation” could be on the nodes, possible operations are:
    • preops: automatic, before entering the state/activity
    • postops: automatic, when leaving the state/activity
    • actions: can be chosen by the owner in the list at the bottom, and/or drop-down/pop-up together with the default actions of leaving the node on one of the arrows.

This appears to add complexity without adding functionality; please provide a detailed example where these additions allow something currently impossible to implement.

  • operations could be anything: sum up the time used for the activity, or just write some statistical fields like

A workflow plugin can add an arbitrary workflow operation, so this is already possible.

  • set_actor should be an operation allowing to set the owner, e.g. as a “preop”:
    • either to a role, a person
    • entered fix at define time, or at run time, e.g. out of a field, or select.

This is either duplicating the existing set_owner operation, or needs to be clarified.

  • Actions should be selectable based on the ticket type (different Workflows for different tickets)

Bakers, Chefs, Cooks – Oh My!

Bakers love to use shortcuts to make their baking easier, but there is a genuine lack of satisfaction if your creations aren’t 100% made from scratch. This is why searching for and using cake recipes on Recipe Bridge can be the most rewarding baking experience.

From the basic sponge cake, to the seven tiered wedding cake, to the savory fish cake – all recipes come with clear and specific instructions designed to make the whole cake-baking experience so much simpler.

If you are a beginner, first try making some Rock Cakes. They are simple, don’t take long to bake, are great to share and are absolutely delicious. All you need is self raising flour, egg, sugar, milk, mixed spice, butter and currants. The dough for these cakes is easy to make and can be formed into whatever size cake you like. They only take 10-15 minutes to bake and are perfect served with a hot cup of tea as an afternoon treat to keep those hunger pangs at bay!

During the festive season, it is the perfect time to try and make a Traditional Christmas Cake. Not only is this creation packed full of booze and loads of seasonal fruits, the mixed spice and cinnamon that go into it give it a rich yet warming winter flavor. It can take 2 ½ to 3 hours to bake but if you have taken the time to do it properly and have topped it with melted chocolate; it will be well worth the wait.

If you are looking for something more complicated still, try a recipe search for the lightly textured Sponge Cake. Although a recipe such as this requires a lot of whisking and patience to ensure you get the right texture for each layer, the result is a phenomenally sweet yet delightful dessert which can be served with all the family at large gatherings.

Get Pumped, Ripped & Ready for Summer

Body building is not just about looking good but also being able to push yourself and enhance your strength. The best bodybuilding supplements for building muscle can help you boost your levels of endurance whilst simultaneously building muscle and therefore strength. Vigorous exercise can take its toll on your body, so it is important to use muscle mass supplements to keep yourself healthy and your muscles well supported.

Muscle supplements, such as Kynoselen and Parabol can be taken with meals and are convenient for fitting into your exercise regime and diet plans. Usually found in tablet form, supplements for muscle building are easy to consume and can be taken with you to work or when you’re at the gym.

Advertising Right, the First Time

Depending on the types of advertising ideas you employ to make an effective advertising campaign, you will know that online advertising has recently proven to be a much more valuable way of promoting your product, brand, or company.

With the growth of the internet has come the growth of internet advertising including CPM (Click Per Impression) advertising and Private Exchanges. Where traditional forms of marketing can be expensive and not totally effective, different forms of internet marketing are not only cheaper than traditional media, but they are also a lot more efficient.

The idea of cpm advertising is to pay per one thousand ‘impressions’ on an internet ad. Using geographical analytics, certain adverts can be displayed to specific demographics so that adverts that get clicks can generate revenue.

As well as CPM advertising, Private Exchanges have also gained popularity amongst publishers and advertisers over the past year. A private exchange is a marketing platform where Real Time Bidding (RTB) can take place between both publishers and advertisers. Publishers can use these platforms to target specific buyers and use these marketplaces as a way to sell on unsold inventory i.e. advertising spaces.

A private exchange allows publishers more control than an open exchange – open exchanges can mean that any advertiser has the possibility of purchasing your inventory. However, a private exchange allows the publisher to privately sell specific inventory to relevant advertisers and control the price. For example, a food publisher with many associate sites may have spare inventory left to fill; with this in mind, the space can be filled by an advertiser’s food product or recipe book etc.

Along with banner ads, pre roll video advertising, mobile advertising and social network advertising, both CPM and private exchange have proven to be amongst the most popular advertising trends of 2011. With the ever growing use of the internet, next year is sure to bring up many new media marketing methods.

How to Get Foreclosure Help

There are a few different stages of foreclosure. This is the process that can occur when a homeowner fails to pay his or her mortgage on time or in full. Not being able to pay is often not the owner’s fault and can be the result of death, divorce, or unemployment. If a homeowner fails to make the first payment but then manages to get up to date with payments soon after, the foreclosure process need not go ahead.

Many foreclosure laws can vary from state to state, but one of the general laws is that when a payment isn’t made, a lender gives the homeowner 90 days to make a payment. If this payment demand is ignored and not met, then proceedings begin shortly afterwards.

Some extreme cases will see people being evicted from their homes, so to avoid this extremity many people hire a reliable foreclosure lawyer to get them through the proceedings. These lawyers can then assist the homeowner with negotiations for an alternative payment plan that will suit both parties – the owner can then keep their house and the lender can still benefit from payment (albeit a different contract to the original one).

We Love our Dogs

Ideal for training your dog, pet containment systems have gained popularity over the past few years due to their effective and humane training method. With an electric fence for dogs or cats, you can keep your pet safe within a space without totally restricting their movement.

Training your cat or dog to stay in your front or back yard can be difficult, especially if they like to break the rules! Even when you have taught them to stay within a particular space, it can then be difficult to teach them that jumping in your pool, burying things in the sandbox or digging up your vegetable patch is wrong.

A dog fence wireless system can come either with or without a wire that you bury around the perimeters of your home. Some wireless systems simply send out a signal which sends a correction to the receiver on your dog or cat’s collar when they go out of their designated area.

The correction is no more than a mild electric shock (similar to the feeling you get with static) although this is seen to be cruel by some, it is genuinely not painful to your pet. As cats are smaller animals, even less severe corrections are sent to the cat’s collar when using a cat fence system.

Keep your pet safe in a cost effective and humane way by using a wireless pet fence – it is the best training method you could employ.

Time for a Massage

Often used for treating both upper and lower back pain, chiropractic massages have also been known to treat other ailments as well. A Bellevue chiropractor is a medical expert who is trained in the field of spine manipulation where they use their hands to massage areas around the spine.

An Issaquah massage can loosen tense back muscles which can mean that you can move with more ease so that you feel more relaxed overall. The idea of chiropractic care is mainly about relieving the pressure in your muscles. By stimulating your muscles with a relaxing chiropractic massage, your circulation can improve and oxygen can flow better around your body – which is great for keeping your brain alert as this can improve your mental capacity too.