<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Apr 30, 2008, at 11:29 AM, Morten Guldager wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Right above the two use statements I had to add:<br>use lib '/usr/share/request-tracker3.6/lib';<br><br>But when running the program it complains:<br>[Wed Apr 30 15:24:54 2008] [crit]: Can't call method "new" on an undefined value at ./test5 line 12. (/usr/share/request-tracker3.6/lib/RT.pm:317)<br> Can't call method "new" on an undefined value at ./test5 line 12.<br><br>Is my RT installation broken? <br>It's an out of the box Debian-4.0 install, request-tracker3.6 (3.6.1-4)</blockquote><div><br></div><div>Try</div><div>my $ticket = RT::Ticket->new( $RT::SystemUser );</div><br><blockquote type="cite"><br><br><br>/Morten %-)<br> <br><div class="gmail_quote">On Wed, Apr 30, 2008 at 4:08 PM, Todd Chapman <<a href="mailto:todd@chaka.net">todd@chaka.net</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> use RT;<br>use RT::Ticket;<br><br>RT::LoadConfig();<br>RT::Init();<br><br>$ticket = $RT::Ticket->new( $RT::SystemUser );<br>$ticket->Load( 123 );<br><br>print $ticket->Subject;<br><br><div class="gmail_quote"><div> <div></div><div class="Wj3C7c">On Wed, Apr 30, 2008 at 9:50 AM, Morten Guldager <<a href="mailto:morten.guldager@gmail.com" target="_blank">morten.guldager@gmail.com</a>> wrote:<br> </div></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="Wj3C7c">'Aloha!<br><br>Below you see the text book example (from RT Essentials) using DBIx::SearchBuilder to accessing the Tickets table from a stand alone perl program.<br> 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?)<br> <br>Simply replacing DBIx::SearchBuilder with RT did not work. (well I sorta did not expect that either..)<br> - and where do I feed it the username/password?<br><br>This must have been done a million times before, but google refuses to help me :-(<br> <br>Anyone?<br><br>-- <br>/Morten %-)<br><br><br>#!/usr/bin/perl<br>use strict;<br>use warnings;<br><br>my $X = tkt->new;<br>$X->Load(123);<br>printf STDERR "%s: %s (%s)\n", $X->id, $X->Subject, $X->Status;<br> <br>package tkt;<br>use strict;<br>use warnings;<br>use DBIx::SearchBuilder::Handle;<br>use base qw(DBIx::SearchBuilder::Record);<br><br>sub _Init<br>{<br> my $self = shift;<br> my $handle= DBIx::SearchBuilder::Handle->new;<br> $handle->Connect(Driver => 'mysql',<br> Database => 'rtdb',<br> User => 'rtuser',<br> Password => $ENV{RTDBPW});<br> $self->_Handle($handle);<br> $self->Table('Tickets');<br>}<br><br>sub _ClassAccessible<br>{<br> return { Id => {read => 1},<br> Status => {read => 1},<br> Subject => {read => 1}<br> };<br> }<br><br> <br></div></div>_______________________________________________<br> <a href="http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users" target="_blank">http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users</a><br> <br> Community help: <a href="http://wiki.bestpractical.com" target="_blank">http://wiki.bestpractical.com</a><br> Commercial support: <a href="mailto:sales@bestpractical.com" target="_blank">sales@bestpractical.com</a><br> <br> <br> Discover RT's hidden secrets with RT Essentials from O'Reilly Media.<br> Buy a copy at <a href="http://rtbook.bestpractical.com" target="_blank">http://rtbook.bestpractical.com</a><br></blockquote></div><br> </blockquote></div><br> _______________________________________________<br><a href="http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users">http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users</a><br><br>Community help: http://wiki.bestpractical.com<br>Commercial support: sales@bestpractical.com<br><br><br>Discover RT's hidden secrets with RT Essentials from O'Reilly Media. <br>Buy a copy at http://rtbook.bestpractical.com</blockquote></div><br></body></html>