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

Dieter Maurer dieter at handshake.de
Thu Aug 12 16:19:48 EDT 2004


Paolo Bizzarri wrote at 2004-8-10 09:44 +0200:
> ...
>from Products.TemporaryFolder.TemporaryFolder import constructTemporaryFolder
>
>def manage_addMyFolderCache(container, id, title='')
>	mfc = MyFolderCache(id, title)
>	container._setObject(id, mfc)

The standard way is:

    destination.manage_addProduct[product_name].constructor(...).

When you follow the standard way, you avoid FMEs (Frequently Made Errors)
such as the above: "mfc" is not acquisition wrapped!

>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?

Did you extend the Zope configuration?
Such that you have a second temporary storage that can be mounted
at your place?

>2) how can I do what I want to do in a single transaction?

I fear you will need your own MountPoint logic that
does not depend an preconfigured storages in Zope's configuration
file.

-- 
Dieter


More information about the Zope-Dev mailing list