[rt-users] Using the RT Codebase in a stand alone program (perl)

Morten Guldager morten.guldager at gmail.com
Thu May 1 05:06:50 EDT 2008


On Wed, Apr 30, 2008 at 6:25 PM, Kevin Falcone <falcone at bestpractical.com>
wrote:

> Try
> my $ticket = RT::Ticket->new( $RT::SystemUser );
>

Wooho! It works! Don't ask me to explain why....

Below is my program as it looks now. Since I don't want to run it as root I
hacked some of the constants from the RT_SiteConfig.pm directly into the
code itself.

But the way I did it, by making my own "package RT"... looks ugly.

Sugestions?

-- 
/Morten %-)

#!/usr/bin/perl

package RT;
our $DatabaseType     = 'mysql';
our $DatabaseUser     = 'rtuser';
our $DatabasePassword = 'dbpw';
our $DatabaseName     = 'rtdb';

package main;
use strict;
use warnings;
use Data::Dumper;

use lib '/usr/share/request-tracker3.6/lib';
use RT;
use RT::Tickets;

RT::Init();

my $u = RT::CurrentUser->new( 'cust-12345' );
die "Password error\n" unless RT::CurrentUser::IsPassword($u, 'magic');

my $ticket = new RT::Ticket($u);
$ticket->Load( 286 );
printf "%5s: %-50s (%s)\n", $ticket->id, $ticket->Subject, $ticket->Status;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20080501/752b1837/attachment.htm>


More information about the rt-users mailing list