[Zope-CMF] set the id of a new cmf object in the factory method

Aaron Payne aaron@aaronpayne.com
Fri, 13 Sep 2002 12:30:58 -0500


Hi all,

I'm trying to set the id of a new cmf object in the factory method and 
I'm hitting a wall.
I need to get an attribute of the cmf site and then increment it by 1.
In the factory method I have:

def addBibliography(self, id , title='', bibliography_reference_id='', 
volume='', search_words=''):
     """Create an empty bibliography."""

     portal_url = getToolByName(self, 'portal_url')
     currentN=portal_url.bibliography_reference_count
     newN=currentN+1
     id='BIB'+str(newN)
     bibliography_reference_id=id
     
portal_url.manage_changeProperties({'bibliography_reference_count':newN})

When I attempt to add an object to a folder I receive an AttributeError.

Traceback (innermost last):
   File /usr/local/zope/Zope2.5.1/lib/python/ZPublisher/Publish.py, line 
150, in publish_module
   File /usr/local/zope/Zope2.5.1/lib/python/ZPublisher/Publish.py, line 
114, in publish
   File /usr/local/zope/Zope2.5.1/lib/python/Zope/__init__.py, line 159, 
in zpublisher_exception_hook
     (Object: spvi)
   File /usr/local/zope/Zope2.5.1/lib/python/ZPublisher/Publish.py, line 
98, in publish
   File /usr/local/zope/Zope2.5.1/lib/python/ZPublisher/mapply.py, line 
88, in mapply
     (Object: invokeFactory)
   File /usr/local/zope/Zope2.5.1/lib/python/ZPublisher/Publish.py, line 
39, in call_object
     (Object: invokeFactory)
   File 
/usr/local/zope/Zope2.5.1/lib/python/Products/CMFCore/PortalFolder.py, 
line 362, in invokeFactory
     (Object: spvi)
   File 
/usr/local/zope/Zope2.5.1/lib/python/Products/CMFCore/TypesTool.py, line 
824, in constructContent
     (Object: portal_types)
   File 
/usr/local/zope/Zope2.5.1/lib/python/Products/CMFCore/TypesTool.py, line 
514, in constructInstance
     (Object: Bibliography)
   File /usr/local/zope/Zope2.5.1/lib/python/OFS/ObjectManager.py, line 
232, in _getOb
     (Object: spvi)
AttributeError: (see above)

How does one get to the cmf site from the factory method?

thanks,
Aaron
____________________________________
Aaron Payne
email: aaron@aaronpayne.com
web: http://www.aaronpayne.com