[Zope] Why can't I use a method of an objectmanger I am trying to add to
?
Dieter Maurer
dieter@handshake.de
Thu, 13 Sep 2001 22:47:38 +0200 (CEST)
=?iso-8859-1?Q?Max=5FM=F8ller=5FRasmussen?= writes:
> I have an objectmanager that implements:
>
> def _getNewId(self):
> """
> generates a new unique id for a message
> get new id and make a zero-padded string
> """
> # 12 chars long, 999,999,999,999 messages max in one discussion!
> newID = '%012d' % self._newId
> self._newId += 1
> self._p_changed = 1
> return newID
>
> And it works nicely if I call it directly.
>
> But when I try to call the method from an object being added to the
> objectmanager like this:
>
> ------------------------------------------------------
>
> def manage_addMessageAction(self,
> title='No title',
> comment='No comment',
> author='No author',
> email='',
> parent=None,
> REQUEST=None, RESPONSE=None):
>
> "Adds a message to the objectmanager"
>
> id = self._getNewId()
>
> .... etc.
Your "self" is here not your Object Manager but a factory instance.
The Object Manager is in the acquisition chain of the factory
and by this way, you can usually acquire method of the Object
Manager. However, "_getNewId" begins with a "_" and such
attributes are not acquired unless explicitly requested.
Dieter