Darin Lee wrote:
Zopisitas,
I am building a threaded discussion product which integrates with a news article product I recently wrote. Inside of the article (folderish Zclass) I would like to allow my users to post "reponses." Where I am running into problems is that I would like to limit my "reply-to" depth to only three levels.
In other words, I would like to limit a user to only adding three subdirectories in a directory, or 3 folderish objects (responses) beneath a single folderish object (discussion folder). Is there an easy way to check for this? How does one accomplish this in zope?
Thanks in advance, -Darin Lee
You could define a method on the folderish ZClass called "depth" that checks it's parent's depth if any and adds one to it. A python script like so could do it (untested): parent = context.aq_parent if _.hasattr(parent, 'depth'): return parent.depth() + 1 else: return 1 or with DTML: <dtml-with aq_parent only> <dtml-if depth> <dtml-return expr="depth()"> <dtml-else> <dtml-return expr="1"> </dtml-if> </dtml-with> Then have the constructor of your article ZClass check the depth and raise an error if it exceeds your threshold. -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>