Re: [rt-users] RT 4.0.2: Custom Condition Fails
Module refresh in development mode sometimes fails to load changed code. Regards, Ruslan. From phone. 14.10.2011 17:40 пользователь Kevin Falcone falc...@bestpractical.com написал: What's odd is that the scrip worked just fine this morning, at least once (I swear I made no changes!): Oct 14 07:20:46 rt2 RT: rt-4.0.2-3121-1318591246-1717.1267-14-0@InforMed,LLC #1267/20086 - Scrip 14 On After Hours Create Notify On-call Support Desk Staff (/ usr/local/rt/sbin/../lib/RT/Action/SendEmail.pm:301) However, tickets created during business hours are again throwing the error related to a missing new() method. I'll double-check the condition module's name, permissions, and directory/path permissions again, to be certain. If it breaks sometimes and not others, something changed. It may be as simple as permissions changing and then a new apache child being spawned, but you'll need to figure out what is different. -kevin RT Training Sessions (http://bestpractical.com/services/training.html) * San Francisco, CA, USA — October 18 19, 2011 * Washington DC, USA — October 31 November 1, 2011 * Barcelona, Spain — November 28 29, 2011 RT Training Sessions (http://bestpractical.com/services/training.html) * San Francisco, CA, USA October 18 19, 2011 * Washington DC, USA October 31 November 1, 2011 * Barcelona, Spain November 28 29, 2011
Re: [rt-users] RT 4.0.2: Custom Condition Fails
On Thu, Oct 13, 2011 at 10:35:40PM -0400, Ryan Frantz wrote: Are you getting this error on startup or during the execution of the scrip (during ticket creation). Oct 13 22:20:57 rt2 RT: Scrip IsApplicable 14 died. - Can't locate object method new via package RT::Condition::OnAfterHoursCreate at /usr/local/rt/sbin/../lib/RT/ScripCondition.pm line 173. Stack: [/usr/local/rt/sbin/../lib/RT/ScripCondition.pm:173] [/usr/local/rt/sbin/../lib/RT/Scrip.pm:404] [/usr/local/rt/sbin/../lib/RT/Scrips.pm:225] [/usr/local/rt/sbin/../lib/RT/Transaction.pm:179] [/usr/local/rt/sbin/../lib/RT/Record.pm:1447] [/usr/local/rt/sbin/../lib/RT/Ticket.pm:669] [/usr/local/rt/sbin/../lib/RT/Interface/Web.pm:1389] [/usr/local/rt/share/html/Ticket/Display.html:127] [/usr/local/rt/share/html/Ticket/Create.html:444] [/usr/local/rt/sbin/../lib/RT/Interface/Web.pm:538] [/usr/local/rt/sbin/../lib/RT/Interface/Web.pm:285] [/usr/local/rt/share/html/autohandler:53] (/usr/local/rt/sbin/../lib/RT/Scrip.pm:419) The name of the custom condition is OnAfterHoursCreate and it is located under myRtRoot/local/lib/RT/Condition/. What's odd is that when I look at the system condition modules, I don't see a new() method defined so I'm not sure why this error is occuring for me. For reference, this is the code for the custom condition: The new() method is defined in RT::Condition Generally, this error means some typo between: The filename The package package RT::Condition::OnAfterHoursCreate; The exec module ExecModule = 'OnAfterHoursCreate', Since at least 2 of those look fine, I'd double-check the filename and permissions on the file (and on the directories leading to the file). Incidentally, if you're going to write a number of these, you may find it useful to write an initialdata file: cat customconditions @ScripConditions = ( {Name = 'On After Hours Create', Description = 'A ticket is created after hours', ExecModule = 'OnAfterHoursCreate', ApplicableTransTypes = 'Create', } ); ./sbin/rt-setup-database --action insert --datafile customconditions Which is a slightly simpler way to register your custom condition. -kevin pgpepWl5H4pqk.pgp Description: PGP signature RT Training Sessions (http://bestpractical.com/services/training.html) * San Francisco, CA, USA October 18 19, 2011 * Washington DC, USA October 31 November 1, 2011 * Barcelona, Spain November 28 29, 2011
Re: [rt-users] RT 4.0.2: Custom Condition Fails
- Original Message - From: Kevin Falcone falc...@bestpractical.com To: rt-users@lists.bestpractical.com Sent: Friday, October 14, 2011 9:01:48 AM Subject: Re: [rt-users] RT 4.0.2: Custom Condition Fails On Thu, Oct 13, 2011 at 10:35:40PM -0400, Ryan Frantz wrote: Are you getting this error on startup or during the execution of the scrip (during ticket creation). I'm getting the error during ticket creation. ... The name of the custom condition is OnAfterHoursCreate and it is located under myRtRoot/local/lib/RT/Condition/. What's odd is that when I look at the system condition modules, I don't see a new() method defined so I'm not sure why this error is occuring for me. For reference, this is the code for the custom condition: The new() method is defined in RT::Condition Generally, this error means some typo between: The filename The package package RT::Condition::OnAfterHoursCreate; The exec module ExecModule = 'OnAfterHoursCreate', Since at least 2 of those look fine, I'd double-check the filename and permissions on the file (and on the directories leading to the file). Kevin, What's odd is that the scrip worked just fine this morning, at least once (I swear I made no changes!): Oct 14 07:20:46 rt2 RT: rt-4.0.2-3121-1318591246-1717.1267-14-0@InforMed,LLC #1267/20086 - Scrip 14 On After Hours Create Notify On-call Support Desk Staff (/ usr/local/rt/sbin/../lib/RT/Action/SendEmail.pm:301) However, tickets created during business hours are again throwing the error related to a missing new() method. I'll double-check the condition module's name, permissions, and directory/path permissions again, to be certain. Incidentally, if you're going to write a number of these, you may find it useful to write an initialdata file: cat customconditions @ScripConditions = ( {Name = 'On After Hours Create', Description = 'A ticket is created after hours', ExecModule = 'OnAfterHoursCreate', ApplicableTransTypes = 'Create', } ); ./sbin/rt-setup-database --action insert --datafile customconditions Which is a slightly simpler way to register your custom condition. I'll keep this handy for future reference. Thanks, Ryan -kevin RT Training Sessions (http://bestpractical.com/services/training.html) * San Francisco, CA, USA October 18 19, 2011 * Washington DC, USA October 31 November 1, 2011 * Barcelona, Spain November 28 29, 2011
Re: [rt-users] RT 4.0.2: Custom Condition Fails
What's odd is that the scrip worked just fine this morning, at least once (I swear I made no changes!): Oct 14 07:20:46 rt2 RT: rt-4.0.2-3121-1318591246-1717.1267-14-0@InforMed,LLC #1267/20086 - Scrip 14 On After Hours Create Notify On-call Support Desk Staff (/ usr/local/rt/sbin/../lib/RT/Action/SendEmail.pm:301) However, tickets created during business hours are again throwing the error related to a missing new() method. I'll double-check the condition module's name, permissions, and directory/path permissions again, to be certain. If it breaks sometimes and not others, something changed. It may be as simple as permissions changing and then a new apache child being spawned, but you'll need to figure out what is different. -kevin pgpbxokgyMMJk.pgp Description: PGP signature RT Training Sessions (http://bestpractical.com/services/training.html) * San Francisco, CA, USA October 18 19, 2011 * Washington DC, USA October 31 November 1, 2011 * Barcelona, Spain November 28 29, 2011
[rt-users] RT 4.0.2: Custom Condition Fails
List, I recently created a custom condition to match tickets created after hours so that I could use it in a scrip to send a copy of the ticket information to the on-call Support Desk tech. I first tested it successfully on an old RT 3.8.8 installation and then started testing it in my RT 4.0.2 installation. I get the following error: Oct 13 22:20:57 rt2 RT: Scrip IsApplicable 14 died. - Can't locate object method new via package RT::Condition::OnAfterHoursCreate at /usr/local/rt/sbin/../lib/RT/ScripCondition.pm line 173. Stack: [/usr/local/rt/sbin/../lib/RT/ScripCondition.pm:173] [/usr/local/rt/sbin/../lib/RT/Scrip.pm:404] [/usr/local/rt/sbin/../lib/RT/Scrips.pm:225] [/usr/local/rt/sbin/../lib/RT/Transaction.pm:179] [/usr/local/rt/sbin/../lib/RT/Record.pm:1447] [/usr/local/rt/sbin/../lib/RT/Ticket.pm:669] [/usr/local/rt/sbin/../lib/RT/Interface/Web.pm:1389] [/usr/local/rt/share/html/Ticket/Display.html:127] [/usr/local/rt/share/html/Ticket/Create.html:444] [/usr/local/rt/sbin/../lib/RT/Interface/Web.pm:538] [/usr/local/rt/sbin/../lib/RT/Interface/Web.pm:285] [/usr/local/rt/share/html/autohandler:53] (/usr/local/rt/sbin/../lib/RT/Scrip.pm:419) The name of the custom condition is OnAfterHoursCreate and it is located under myRtRoot/local/lib/RT/Condition/. What's odd is that when I look at the system condition modules, I don't see a new() method defined so I'm not sure why this error is occuring for me. For reference, this is the code for the custom condition: package RT::Condition::OnAfterHoursCreate; use warnings; use strict; use base 'RT::Condition'; sub IsApplicable { my $self = shift; my $weekday = (localtime)[6]; my $min = (localtime)[1]; my $hour = (localtime)[2]; return 1 if $weekday == 6 || $weekday == 0; return 1 if $hour = 17 || ( $hour = 8 $min = 29); return 0; # no match } 1; I used the following Perl script to register the condition within RT: #!/usr/bin/perl use strict; use lib /usr/local/rt/lib; use RT; use RT::Interface::CLI qw( CleanEnv GetCurrentUser ); use RT::ScripCondition; CleanEnv(); RT::LoadConfig(); RT::Init(); my $user = GetCurrentUser(); unless( $user-Id ) { print No RT user found. Please consult your RT administrator.\n; exit 1; } my $sc = RT::ScripCondition-new($user); $sc-Create( Name = 'On After Hours Create', Description = 'A ticket is created after hours', ExecModule = 'OnAfterHoursCreate', ApplicableTransTypes = 'Create', ); I built the custom condition and registration code from an example I found in the 'RT Essentials' book published by O'Reilly. In fact, it's a 99% lift from that book. The only difference I noted that was required for custom conditions in RT 4 was the need to change use base 'RT::Condition:Generic'; to use base 'RT::Condition';. Am I missing something in general? Or am I missing something specific to RT 4? Ryan RT Training Sessions (http://bestpractical.com/services/training.html) * San Francisco, CA, USA October 18 19, 2011 * Washington DC, USA October 31 November 1, 2011 * Barcelona, Spain November 28 29, 2011