[Freeipa-devel] [PATCH] 54 Fix attempted write to attribute of read-only object

Jan Cholasta jcholast at redhat.com
Fri Dec 2 15:01:45 UTC 2011


Dne 2.12.2011 15:56, Rob Crittenden napsal(a):
> Jan Cholasta wrote:
>> Dne 14.10.2011 10:19, Alexander Bokovoy napsal(a):
>>> On Fri, 14 Oct 2011, Jan Cholasta wrote:
>>>> Perform an HTTP request.
>>>> """
>>>> - if self.ca_host == None:
>>>> - self.ca_host = self._select_ca()
>>>> + if self.ca_host is None:
>>>> + object.__setattr__(self, 'ca_host', self._select_ca())
>>>> return dogtag.http_request(self.ca_host, port, url, **kw)
>>> I don't like this approach as well. A better way would be to have a
>>> class CaCache that is mutable and allow changing its properties. Then
>>> you would create an instance of CaCache in ca.__init__() and ask for
>>> its properties later.
>>
>> I don't like the idea of introducing a new class every time we need a
>> ReadOnly attribute to be writable. There's quite a few places in the
>> code where we do object.__setattr__ on ReadOnly objects. IMO the right
>> thing to do would be to add means of whitelisting ReadOnly attributes
>> that need to stay writable after locking.
>>
>>>
>>> You can move those _select_ca(), _select_any_master(),
>>> _host_has_service() to CaCache as they seem to not depend on anything
>>> in class ca but rather use global api.env.
>>>
>>> This way you will get is a fairly simple CaCache class reusable both
>>> in ca and ra classes.
>>
>> Honza
>>
>
> What is the status of this patch?
>
> rob

It fixes the issue and I wouldn't mind leaving it as it is.

Alexander?

Honza

-- 
Jan Cholasta




More information about the Freeipa-devel mailing list