[Zope-dev] Why is it _setObject(), and why is it undocumented
Leonardo Rochael Almeida
leo@hiper.com.br
03 Feb 2003 18:42:04 -0200
On Sat, 2003-02-01 at 12:16, Max M wrote:
> Lennart Regebro wrote:
> > From: "maxm" <maxm@mxm.dk>
> >
> >>Usually a private method is used purely as a mean of implementation. And
> >>should never be called from other objects. This is not the case here, as
> >>the method is clearly a part of the api.
> >
> >
> > Well, no, it isn't really, since it starts with _. However, python do not in
> > itself enforce privacy, so therefore you *can* call it. But by starting it
> > with _ it is private by convention. Zope also implements some of this
> > privacy, so you can't call it from Python scripts and so on.
>
> Sorry but I don't see that. How on earth are you suposed to add an
> object to an objectmanager, if you don't use _setObject() ??
>
> Every time you make an object that subclasses ObjectManager, wich is
> often, you need to use that function. That can hardly be called private.
The problem here are not the subclasses of OM, but all objects that are
supposed to be added to an objectManager. There is no other method in
the OM class to add an object to an OM instance so it's obviously not a
"private" method (in the "others shouldn't be calling it" sense). All
objects that are designed to be added to an OM instance call it either
in their __init__ or in a factory function (like manage_addSomething())
Let's not confuse this with TTW public methods. _setObject should
obviously not be made TTW accessible (let alone TTW public :-), but it
should be a "public" method, that is, have a sensible name and be
specified in an eventual IObjectManager interface
--
Ideas don't stay in some minds very long because they don't like
solitary confinement.