[Zope-dev] Problem acquiring via a newly created object

Richard Barrett R.Barrett@ftel.co.uk
Fri, 21 Jul 2000 13:18:42 +0100


I'm stumbling to find a solution to the following problem.

Using python I have created two classes which respectively derive 
from the standard Zope Folder class and DTMLDocument class.

My classes (and some others yet to be written) are intended for use 
when requirements stipulate that published material must be 
held/protected in RCS as well as being served via Zope. I've elected 
to put an attribute called 'web_RCS_root' at the top of the Zope 
object hierarchy which contains the server local file system path 
under which files to be held by RCS.

When instances of the Folder derived class are created, the add 
function creates a file system folder below the 'web_RCS_root'. The 
add function for my folderish objects effectively creates a directory 
hierachy in the file system isomorphic to the hierachy of the URL's 
being served by Zope.

Instances of my DTMLDocument derived class are only allowed within my 
Folder derived class. The add document function that creates them and 
the edit function for them use RCS check-in to preserve copies of the 
document contents.

I'm using the following python expression in the manage_addFolder and 
manage_addDocument functions to determine the location in the file 
system for the RCS backup of the data.

rcspath = os.path.normpath(getattr(self, 'website_RCS_root') + \
                            '/' + self.absolute_url(1) + \
                            '/' + ob.id)

As you can see it depends an acquiring the value of the 
'website_RCS_root' attribute from its containment environment.

This works fine for both folder-like and document-like classes if the 
add functions are called from the management interface.

However, I want to create an instance of my document class within the 
containment of an instance of my folder class while creating that 
instance of my folder class. Just like creating a public interface 
(index_html) as part of creating a regular folder, which is what my 
code is based on.

I'm doing this by calling my  manage_addDocument function from within 
the my manage_addFolder function. But this fails with Zope reporting 
an AttributeError of the acquired attribute 'website_RCS_root'.

My best guess as to why goes something like: "until the transaction 
in which the folder is created is committed, the acquisition of 
attributes higher in the containment hierarchy will fail. As you are 
trying to create the document in the same transaction this is bound 
to fail", but I've no proof this is the problem.

What's going wrong and what's a good solution to the problem.

I'm working with Zope 2.1.6 running under Suse 6.4 Linux on an x86 processor.
------------------------------------------------------------------
Richard Barrett, PostPoint 27,         e-mail:r.barrett@ftel.co.uk
Fujitsu Telecommunications Europe Ltd,      tel: (44) 121 717 6337
Solihull Parkway, Birmingham Business Park, B37 7YU, England
"Democracy is two wolves and a lamb voting on what to have for
lunch. Liberty is a well armed lamb contesting the vote."
Benjamin Franklin, 1759
------------------------------------------------------------------