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

Morten Guldager morten.guldager at gmail.com
Wed Apr 30 09:50:29 EDT 2008


Below you see the text book example (from RT Essentials) using
DBIx::SearchBuilder to accessing the Tickets table from a stand alone perl
Since I need restricting access to what a specific user would be allowed to
do, I think I have to transform this code into something using RT::Record
(or should it be RT::Ticket?)

Simply replacing DBIx::SearchBuilder with RT did not work. (well I sorta did
not expect that either..)
 - and where do I feed it the username/password?

This must have been done a million times before, but google refuses to help
me :-(


/Morten %-)

use strict;
use warnings;

my $X = tkt->new;
printf STDERR "%s: %s (%s)\n",  $X->id,  $X->Subject,  $X->Status;

package tkt;
use strict;
use warnings;
use DBIx::SearchBuilder::Handle;
use base qw(DBIx::SearchBuilder::Record);

sub _Init
  my $self = shift;
  my $handle= DBIx::SearchBuilder::Handle->new;
  $handle->Connect(Driver   => 'mysql',
                   Database => 'rtdb',
                   User     => 'rtuser',
                   Password => $ENV{RTDBPW});

sub _ClassAccessible
  return { Id      => {read => 1},
           Status  => {read => 1},
           Subject => {read => 1}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20080430/00465c5d/attachment.htm>

More information about the rt-users mailing list