[rt-users] AdminClass right and RT-FM

Jesse Vincent jesse at bestpractical.com
Fri Mar 27 17:42:24 EDT 2009


> I tried to create a small perl script to examine the rights directly:
> 
> #!/usr/bin/perl -w
> 
> use strict;
> 
> use lib qw'/opt/rt3/lib /opt/rt3/local/lib';
> 
> use RT;
> use RT::Interface::CLI qw/GetCurrentUser/;
> 
> RT::LoadConfig;
> RT::Init;
> 
> my $user = GetCurrentUser();
> 
> my $c = RT::FM::Class->new($user);
> 
> $c->Load('someclassname');
> 
> if ($user->HasRight(Right => 'AdminClass',
> 		    Object => $c)) {
>    print "Yes we can\n";
> }
> 
> 
> but I'm not sure I've done this right, because it dies with:
> 
> Can't locate object method "new" via package "RT::FM::Class" (perhaps  
> you forgot to load "RT::FM::Class"?) at test.pl line 15, <DATA> line  
> 273.

RT::FM doesn't pre-load all its classes at startup. so adding:

require RT::FM::Class; 

right before your ->new statement will probably help

note that a 'use' may fail because use is compile-time evaluated...and
that may happen before plugins are innited.

-j

> 
> I've definitely got RT::FM in the @Plugins variable, so does anyone  
> have any clues as to (a) what I might have done wrong with the rights  
> in general and (b) why my little test script above does not work?
> 
> Thanks in advance,
> 
> Tim
> 
> 
> -- 
>  The Wellcome Trust Sanger Institute is operated by Genome Research 
>  Limited, a charity registered in England with number 1021457 and a 
>  company registered in England with number 2742969, whose registered 
>  office is 215 Euston Road, London, NW1 2BE. 
> _______________________________________________
> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
> 
> Community help: http://wiki.bestpractical.com
> Commercial support: sales at bestpractical.com
> 
> 
> Discover RT's hidden secrets with RT Essentials from O'Reilly Media. 
> Buy a copy at http://rtbook.bestpractical.com
> 



More information about the rt-users mailing list