[Zope] adding roles to Zope in Product.initialize()

Jerome Alet alet@unice.fr
Thu, 30 Nov 2000 08:56:22 +0100 (MET)


On Wed, 29 Nov 2000, Randall Kern wrote:

> By "use local roles", you mean do it manually, through the web ui?  I don't
> see how I could create a local role from code either, since none of my
> objects have been created yet.

You can do it in the manage_afterAdd() method of your class:

---CUT---
def manage_afterAdd(self, item, container) :
	# create the role only if it doesn't exist (acquisition)
	if "yourrole" not in container.valid_roles() :
		self._addRole("yourrole")

	#
	# here you may need to call the manage_afetrAdd() method
	# of you base class
	# e.g.: Folder.manage_afterAdd(self, item, container)
---CUT---

So the role will be created in your instance during its creation, but only
if doesn't exist yet (or can't be acquired from the above level).

hoping this will help.

Jerome Alet