On Tuesday 08 January 2008, Hermann Himmelbauer wrote: > My question is: How would I store these documents in the ZODB? If I create > a container object for each user and store the document there, how would > then other users get a "link" to their own folder? Moreover, what happens > if the original owner abandons the document?
You clearly thought about the problem, since you already provided solutions. :-) It all depends how you identify an owner. I do this by checking whether a user has been granted the Owner role locally. Okay, so now we know how to retrieve the information. Next, how can we efficiently extract a list of all the documents a user owns. The answer is a catalog. You can create an index that records the owners of each document. (That should be about 5-10 lines of code.) When you provide the list, you simply return catalog query results, instead of iterating through all items in a folder. What to do when someone abandons a document depends really on your decision where to locate it and how you implement other views. 1. If you have one large container, the solution is simple. You write a subscriber that checks whether the changed object still has an owner. If not, it is deleted. There is not need for more info tracking. 2. If you store the documents locally, and the removed owner matches the location user, I would move the documents either to a global "abandoned" folder or to the user folder of the next user on the list. Which way you want to go, depends on your other design goals. > If I have one huge container that holds all documents, how would then list > users their documents? Use a catalog query. Seriously; it is efficient. > The other issue is how to set up permissions on these objects, would I e.g. > store the owners along with the object (e.g. as an object attribute)? As I said before, I do this using roles. Because you want to assign special permissions for owners anyways. Keeping the information twice, is just a senseless bookkeeping exercise. That said I commonly create a property for these cases: @apply def departmentManagers(): role_id = 'pkg.DepartmentManagerOwner' def get(self): prm = IPrincipalRoleManager(self) return tuple([u for u, p in prm.getPrincipalsForRole(role_id)]) def set(self, value): prm = IPrincipalRoleManager(self) for principal_id, perm in prm.getPrincipalsForRole(role_id): prm.unsetRoleForPrincipal(role_id, principal_id) for principal_id in value: prm.assignRoleToPrincipal(role_id, principal_id) return property(get, set) Regards, Stephan -- Stephan Richter Web Software Design, Development and Training Google me. "Zope Stephan Richter" _______________________________________________ Zope3-users mailing list Zope3email@example.com http://mail.zope.org/mailman/listinfo/zope3-users