I am trying to develop a program that generates a top-level folder within zope and then has one of its functions called to give permission to access the folder, as opposed to using the standard Zope permission system. As I understand it the only way to do this is to modify the core zope software. Am I correct or is there another way to do it? I have looked at OFS.ObjectManager and discovered that the functions _getobj, _setobj, and _delobj are called to get, set and delete an object. Presumably, if I raised an exception here, it would cause the operation to not suceed. I have also figured out how to get the ID and Title of the file, but I can't get the absolute path. How do I tell the absolute path of a file from within OFS.ObjectManager? And, is modifying OFS.ObjectManager to call the function in my program the best place to modify the core of zope? Thank You -- __________________________________________________________ Sign-up for your own FREE Personalized E-mail at Mail.com http://www.mail.com/?sr=signup
On Mon, 2003-03-17 at 04:31, mattficken@mail.com wrote:
I am trying to develop a program that generates a top-level folder within zope and then has one of its functions called to give permission to access the folder, as opposed to using the standard Zope permission system.
I don't think you really need this. Zope authentication/authorization machinery is so flexible that there's usually a way to code whatever you want to achieve thru it instead of around it.
As I understand it the only way to do this is to modify the core zope software.
I don't think you need this either. Zope authentication machinery is very plugable. At the very worst, I think you could get around it by creating a class that inherits from Folder and instantiate from that instead.
Am I correct or is there another way to do it?
There probably is, but it'd be better if we understood what you're trying to do. Try to tell us what you are trying to achieve instead of how you plan on doing it :-)
I have looked at OFS.ObjectManager and discovered that the functions _getobj, _setobj, and _delobj are called to get, set and delete an object. Presumably, if I raised an exception here, it would cause the operation to not suceed.
Yes, but you don't have to change ObjectManager for that. As I mentioned before, you could inherit from folder, override ._setobj() and raise an exception before calling 'Folder._setobj(self, ...)'. You can also raise an exception after you've called those methods, as long as you are still in the same transaction. If the exception is not caught, it aborts the transaction and any changes that happened since it's begining will be discarded.
I have also figured out how to get the ID and Title of the file, but I can't get the absolute path. How do I tell the absolute path of a file from within OFS.ObjectManager?
file.getPhysicalPath() will give you a tuple representation of the object absolute path. '"/".join(file.getPhysicalPath())' will get you the string representation.
And, is modifying OFS.ObjectManager to call the function in my program the best place to modify the core of zope?
As I said, there are a number of options to try before you modify Zope core :-) Cheers, Leo
On March 17, mattficken@mail.com wrote:
I am trying to develop a program that generates a top-level folder within zope and then has one of its functions called to give permission to access the folder, as opposed to using the standard Zope permission system. As I understand it the only way to do this is to modify the core zope software.
Like everything else in Zope, assigning permissions and roles can be done programmatically. So, if you want to dynamically grant a role a particular permission (or conversely, grant a user a role), you could do it with a Python script that calls container.manage_permission or container.manage_role as appropriate, and give that script the Manager proxy role, ensuring it is only callable by appropriate users. But I strongly suspect there is a better way to solve your problem, probably with local roles. If you describe what you're really trying to achieve, perhaps we can help you achieve it in a more Zopish way. When you say "top-level folder", do you mean the root folder (which is not really a folder), or one level down? a. -- Adrian van den Dries adriand@flow.com.au Development team www.dev.flow.com.au FLOW Communications Pty. Ltd. www.flow.com.au
participants (3)
-
Adrian van den Dries -
Leonardo Rochael Almeida -
mattficken@mail.com