Bugzilla::Object->set() protection

Gervase Markham gerv at mozilla.org
Tue May 4 15:00:47 UTC 2010


Bugzilla::Object->set() is protected from being called from outside 
objects which inherit from Bugzilla::Object:

     # This method is protected. It's used to help implement set_ functions.
     caller->isa('Bugzilla::Object')
         || ThrowCodeError('protection_violation',
                           { caller     => caller,
                             superclass => __PACKAGE__,
                             function   => 'Bugzilla::Object->set' });
(Bugzilla/Object.pm line 285 in 3.6).

I am updating an extension which adds fields to the Group and User 
objects. I have used the object_columns hook to add them so generic 
functions know about them. But these two objects do not have a set_all() 
style function, only individual setters for each field which is there by 
default. So there is no setter for me to set the value of my new field.

How do I update the relevant field on the objects (when they are changed 
in the Web UI) apart from calling:

     $group->set('secure_mail', $params->{secure_mail});
or
     $user->set('public_key', $params->{public_key});
?

At the moment, I have to comment out the above four lines of code to get 
this to work. What should I be doing?

More of the code is below.

Gerv



I added the relevant hooks to the "update" functions in editgroups.cgi 
and userprefs.cgi and then have:

# On update, set the value of the secure_mail field from the form 
submission.
sub group_end_of_set_all {
     my ($self, $args) = @_;
     my %args = %{ $args };
     my ($group, $params) = @args{qw(group params)};

     $group->set('secure_mail', $params->{secure_mail});
}

# On update, set the value of the public_key field from the form 
submission.
sub user_end_of_set_all {
     my ($self, $args) = @_;
     my %args = %{ $args };
     my ($user, $params) = @args{qw(user params)};

     $user->set('public_key', $params->{public_key});
}
_______________________________________________
dev-apps-bugzilla mailing list
dev-apps-bugzilla at lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-apps-bugzilla



More information about the developers mailing list