[Freeipa-devel] [PATCH] 54 Fix attempted write to attribute of read-only object
Alexander Bokovoy
abokovoy at redhat.com
Fri Oct 14 08:19:00 UTC 2011
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.
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.
--
/ Alexander Bokovoy
More information about the Freeipa-devel
mailing list