[Zope-dev] AttributeError when adding ZClass product (PortalMembership)

Morten W. Petersen morten@esol.no
26 Jan 2001 16:18:40 +0100


Hi guys,

I have a problem with a product.  This product, let's call it product
SuperSecret, adds a number of folderish objects to the new instance
when it is created.  Now, if we name the SuperSecret product instance for
a, and the class instance that raises the AttributeError b, I
will show you what happens:

I am at the root folder of the Zope instace, and select the SuperSecret
entry from the Products list.  There I enter the relevant information,
and submit the form.  But then, the SuperProduct raises an exception
when the manage_add_some_class function tries to add the new b instance
to the a instance.  (No exception is raised when the offending line
which tries to access the Control_Panel via the b instance & acquisition
is commented out).

The manage method, which looks like this:

	def manage_add_b(self, id, description, REQUEST=None):
		"Add an instance of the b class."

		self._setObject(id, b(id, description))
		#get_transaction().commit()
		Shared.utils.install_authentication_folder(self[id])

which calls an external function, which looks like this:

	def install_authentication_folder(container):

		container.Control_Panel.Products.PortalMembership.doInstall(folder=container, REQUEST={})

which raises an AttributeError that looks like this:

           Zope Error

           Zope has encountered an error while publishing this resource. 

           Error Type: AttributeError
           Error Value: Control_Panel

	   [...]

	  File /home/morten/Zope/lib/python/Products/rs/rs.py, line 56, in manage_add_a
	  File /home/morten/Zope/lib/python/Products/SuperSecret/a.py, line 168, in __init__
	    (Object: CatalogAware)
	  File /home/morten/Zope/lib/python/Products/SuperSecret/b.py, line 61, in manage_add_b
	    (Object: CatalogAware)
	  File /home/morten/Zope/lib/python/Products/SuperSecret/Shared/utils.py, line 211, in install_authentication_folder
	    (Object: CatalogAware)
	  AttributeError: (see above)

Now, I guess this could be because the new instance isn't aware of it's
surroundings, but I've tried to manually commit the transaction (which
could help?), but obviously didn't...  =)

I guess it could be a solution to call a number of methods after the
product instance is added, but that's a bit too hackish for me.

Any ideas?

Thanks in advance,

Morten