Am Sonntag, 27. Januar 2008 18:25 schrieb Stephan Richter:
> 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.
I just wanted to give you feedback about this:
I first decided to go my way and store the documents in the user folder, while
storing copies of these documents in other user folders (in case there are
other owners). However, This did NOT work out in the end:
The problem with copies of objects in multiple containers is that these
objects have the wrong __parent__ atribute, therefore traversing etc. does
not work properly - that was something I did not think about beforehand.
Therefore I redesigned my app to your way where all documents are kept in a
large folder and the owner role is assigned to them. Moreover I have
a "owners" property that lists all owners (=Principals) for this role. This
property can then be indexed.
> > 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.
That's somehow the drawback about the above solution: Retrieving documents via
indexes is very efficient, however, I need to order them after some object
attribute, which seems to be quite painful and slow unless there isn't some
trick with another index. But let's see - for now it's ok, but in case it has
to be scaled upwards I have to think about this issue.
Many thanks for help!
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9 4902 64B4 D16B 2998 93C7
Zope3-users mailing list