[Zope] Why can't I use a method of an objectmanger I am trying to add to
?
Max Møller Rasmussen
maxm@normik.dk
Thu, 13 Sep 2001 13:47:41 +0200
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.
------------------------------------------------------
I get an error:
Error Type: AttributeError
Error Value: _getNewId
Traceback (innermost last):
File C:\zope\zope240\lib\python\ZPublisher\Publish.py, line 223, in
publish_module
File C:\zope\zope240\lib\python\ZPublisher\Publish.py, line 187, in
publish
File C:\zope\zope240\lib\python\Zope\__init__.py, line 226, in
zpublisher_exception_hook
File C:\zope\zope240\lib\python\ZPublisher\Publish.py, line 171, in
publish
File C:\zope\zope240\lib\python\ZPublisher\mapply.py, line 160, in mapply
(Object: manage_addMessageAction)
File C:\zope\zope240\lib\python\ZPublisher\Publish.py, line 112, in
call_object
(Object: manage_addMessageAction)
File C:\zope\zope240\lib\python\Products\mxm_Discuss\mxm_Message.py, line
106, in manage_addMessageAction
AttributeError: (see above)
------------------------------------------------------
line 106 being "id = self._getNewId()"
"manage_addMessageAction" is registered as a constructor. When it is being
called from an ObjectManager, isn't the objectmanager passed to this unbound
method?
If so, why can't it find "_getNewId()"
Regards Max M