[Zope-dev] Folder Subclassing Problem

James W. Howe jwh@allencreek.com
Wed, 23 Feb 2000 17:19:27 -0500


I'm trying to write an extension to Zope which enhances the functionality 
of Folder.  I'm trying to create a new type of folder which limits the 
contents displayed to objects for which the currently authenticated user 
has management permission ('View management screens').  Unfortunately I'm 
seeing behavior which I don't fully understand.

My implementation is fairly straightforward (or at least I think it is).  I 
created a Product subdirectory to hold my enhancement.  I created a .py 
file which contained my new folder class along with a method used to create 
a new instance of the class.  Basically I took the Folder.py class and 
tweaked it.  For example, I called my class a FilteringFolder and had it 
derive from Folder.  I gave my folder it's own meta_type and I defined my 
own manage_main attribute.  My manage_main is an HTMLFile which contains 
the DTML for displaying contents.  It is virtually identical to the 
main.dtml found in OFS except that it uses a different method to get the 
contents.

As the superuser, I created an instance of my folder.  When I created the 
folder, I saw my add form and I've verified that the object created really 
is an instance of FilteringFolder.  To test to see if my contents method 
was being called, I ran Zope in debugging mode and put a pdb.set_trace() 
command inside the method that I expect to be called.  When I attempt to 
view the contents of the folder by clicking on it from the management 
interface I get Zope to halt where I expect it to.  As a second test, I 
close and reopen my browser (to get rid of authentication information) and 
I access my folder with the following url:

http://foo:8080/TestFilteringFolder/manage

I get prompted for login and I again log in as the super user.  Once again, 
the Zope halts where I expect it to.  I then add a user to the acl_users 
folder contained in my FilteringFolder.  I define a new role for this user 
and assign it to my new user.  From the security tab, I let my new role 
have access to 'View management screens', but nothing else.  I then close 
my browser and reopen it.  I try to access the management interface to my 
folder using the URL given above.  This time, instead of authenticating as 
the super user, I authenticate as my new user.  Now, instead of zope 
halting, I get the default index_html screen for the folder.  I don't see 
contents, and as far as I can tell, my manage_main is never invoked.  I 
don't understand this.  I'm sure this is some permission problem, but I 
haven't been able to figure it out.  Can anyone help explain what might be 
happening and what I would need to correct to make this work?  I can 
provide more information if that would help.

Thanks.

James W. Howe				mailto:jwh@allencreek.com
Allen Creek Software, Inc.		pgpkey: http://ic.net/~jwh/pgpkey.html		
Ann Arbor, MI  48103