[Rt-devel] [PATCH] Specify Queue ACLS at queue declaration on initialdata

Jesse Vincent jesse at bestpractical.com
Wed Jan 7 18:59:15 EST 2009




On Wed, Jan 07, 2009 at 03:53:01PM -0800, Chad Granum wrote:
> 
> The patch works by first creating the queue, then adding it as the Queue
> => in each item from ACL, then pushing that list onto the global @ACL
> list so they will be loaded with the others when Handle gets to them.
> 
> Simply put this patch allows you more control over how you organize your
> initialdata while reusing code as much as possible.


Reasonable intent, but the code itself is fairly hard to read.

"$return and $ACL" sounds kind of bizarre. 

Standard convention is ->id rather than ->Id

I'd shy away from using $ACL and @ACL in the same

chunk of code.

$item->{ ACL } isn't really the same as standard RT style. I'd probably
do $item->{'ACL'} instead.

I'd move your new if block to inside the else clause running off the end
of your patch and phrase it as

if (my $acl = delete $item->{'ACL'}) {


}

though I suppose you'd then be passing it into the create, which is
suboptimal.

Well, at least lowercase your variable, since the new allcaps scalar
variable looks like a global ;)



> 
> -Chad Granum
> 
> OpenSourcery (www.opensourcery.com)

> --- lib/RT/Handle.pm-orig	2009-01-07 14:57:06.000000000 -0800
> +++ lib/RT/Handle.pm	2009-01-07 15:24:17.000000000 -0800
> @@ -768,7 +768,14 @@
>          $RT::Logger->debug("Creating queues...");
>          for my $item (@Queues) {
>              my $new_entry = new RT::Queue($RT::SystemUser);
> +            my $ACL = delete $item->{ ACL };
>              my ( $return, $msg ) = $new_entry->Create(%$item);
> +
> +            if ( $return and $ACL ) {
> +                $_->{ Queue } = $new_entry->Id for @$ACL;
> +                push @ACL => @$ACL;
> +            }
> +
>              unless ( $return ) {
>                  $RT::Logger->error( $msg );
>              } else {




> _______________________________________________
> List info: http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-devel


-- 


More information about the Rt-devel mailing list