Trac api

There are many ways to install trac, I use the next one:

# apt-get install apache2-utils # for ubuntu

virtualenv .env --no-site-packages
source .env/bin/activate
easy_install Trac==1.0
easy_install -Z -U
mkdir /PATH_TO_TRAC/mytrac
trac-admin /PATH_TO_TRAC/mytrac initenv # set trac name and database
vim /PATH_TO_TRAC/mytrac/conf/trac.ini
# add to trac.ini:
# [components]
# tracrpc.* = enabled

# create htpasswd file
/usr/sbin/htpasswd -b /PATH_TO_TRAC/mytrac/.htpasswd <username> <pass> # use -c option for first time

# add admin user
trac-admin /PATH_TO_TRAC/mytrac permission add <username> TRAC_ADMIN

# test it
tracd -p 8020 -s --basic-auth="*,/PATH_TO_TRAC/mytrac/.htpasswd,realm" /PATH_TO_TRAC/mytrac
# navigate to

Using trac api to create a new ticket:

import xmlrpclib

API_URL = 'http://<username>:<pass>@'

if __name__ == '__main__':
    attributes = {
        'status': 'new',
        'priority': 'major',
        'type': 'common'
    subject = 'Some issue'
    description = 'Some description ...'
    server = xmlrpclib.ServerProxy(API_URL)
    ticket_id = server.ticket.create(
    print 'Ticket #{ticket_id} was created'.format(ticket_id=ticket_id)

Result (navigate to

Trac ticket


Licensed under CC BY-SA 3.0