Using RT library from outside

Hi all,

I am developping a dedicated interface for RT for a few years, accessing
the DB directly (postgresql only).

I am now rewriting the application completely because we are switching
to an “assetized” version of RT (AssetTracker module).

For many obvious reasons, I’d now like to do all DB writes via RT’s library.

I’m developping in embedded perl (Embperl).

I have a few questions :

  1. Is it possible to use RT::* from “outside” ? Is there a documentation
    somewhere with guidelines (like dealing with sessions) or some examples ?

  2. Is it possible to use the plugins library (explicitly AT’s functions)
    the same way ?

Thanks for your help,

Jean-Christophe Boggio

  1. Is it possible to use RT::* from “outside” ? Is there a
    documentation somewhere with guidelines (like dealing with sessions)
    or some examples ?
    It certainly is, you just load them in a script. I’ve now written
    scripts to do things like scan users out of an SQL database and feed
    them into RT for import (kind of like RT::LDAPImport for SQL, but custom
    for our environment) among other things.

Here’s the prologue I use to get things set up:

use 5.10.1;
use strict;
use warnings;

Customise to fit your environment

use lib qw(/opt/rt4/lib /usr/share/request-tracker4/lib
/usr/local/share/request-tracker4/lib);
use RT;
use RT::Interface::CLI qw( CleanEnv );
use DBI;
use Text::CSV;

say “Setting up rt…”;
CleanEnv();
RT::LoadConfig( );
RT::Init( );

I’m not at all certain that CleanEnv() is necessary; I started off with
an RT CLI script and never got around to tidying it properly. This is
probably far from the perfect way to do the job.

You can use RT::SystemUser when you need a privileged user, or you can
use RT::Interface::CLI::GetCurrentUser to find a user with gecos field
matching the current unix user name.

  1. Is it possible to use the plugins library (explicitly AT’s
    functions) the same way ?

I’ve used my own plugin code from scripts with a simple ‘use
RT::Extension::SMSNotify’ or whatever, but those have been designed not
to make assumptions about the calling context. Whether you can use a
plugin would depend on how the code expects to be called; you can’t just
invoke a Mason callback as simple Perl code, for example.

Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Hi all,

I am developping a dedicated interface for RT for a few years, accessing
the DB directly (postgresql only).

I am now rewriting the application completely because we are switching to
an “assetized” version of RT (AssetTracker module).

For many obvious reasons, I’d now like to do all DB writes via RT’s
library.

I’m developping in embedded perl (Embperl).

I have a few questions :

  1. Is it possible to use RT::* from “outside” ? Is there a documentation
    somewhere with guidelines (like dealing with sessions) or some examples ?

  2. Is it possible to use the plugins library (explicitly AT’s functions)
    the same way ?

Thanks for your help,

As far as I know Embperl is an alternative to HTML::Mason that RT itself
uses, so these projects allow you to embed perl code into HTML, XML, txt or
whatever you generate. RT::* API is UI agnostic part that doesn’t care
about caller. It’s used from mason and command line scripts.


Jean-Christophe Boggio

Best regards, Ruslan.