[Zope-dev] Adding a TemporaryFolder inside a factory method of a Zope class

Paolo Bizzarri p.bizzarri at icube.it
Tue Aug 10 03:44:21 EDT 2004


Hi all.

The scenario

We would like to setup a Zope Class, subclassing the OFS.Folder, which has 
inside a cache. The structure would be something like:

MyFolder
	TemporaryFolder
		MyFolderCache

Therefore, the MyFolderCache cache is inside a temporary folder inside the 
MyFolder.

I've no problem in manually creating this structure. However, we do have 
problems when we try to do this in a factory method. The factory method is 
something like:

from Products.TemporaryFolder.TemporaryFolder import constructTemporaryFolder

def manage_addMyFolderCache(container, id, title='')
	mfc = MyFolderCache(id, title)
	container._setObject(id, mfc)


def manage_addMyFolder(container, id, title='')
	mf = MyFolder(id, title)
	container._setObject(id, mf)

	constructTemporaryFolder(mf, id='tmp', title='')
	manage_addMyFolderCache(mf.tmp, id='cache', title='cache')

The Problem

The problems occur inside manage_addMyFolderCache, when it tries the 
container._setObject. The error is always an AttributeError, because there is 
no _setObject.

After a brief look at the MountedTemporaryFolder class, I can understand that 
there is still no folder inside mf.tmp, because the populate has not been 
called yet.

Now the questions:

1)what is the problem which is occuring?
2) how can I do what I want to do in a single transaction?

Thanks all for the support

Regards
Paolo
-- 
Paolo Bizzarri - President - Icube S.r.l.
Address:   	Via Ridolfi 15 - 56124 Pisa (PI), Italy
E-mail:	p.bizzarri at icube.it	Web:	http://www.icube.it
Phone:	(+39) 050 97 02 07	Fax: 	(+39) 050 31 36 588


More information about the Zope-Dev mailing list