kbond wrote:
So far I already play around in "spe" and get the following: ++++++++++++++++++++++module++++++++++++++++++++++++++ #! /usr/bin/env python
import os, sys sys.path.append("/usr/lib/zope/lib/python") import Zope Zope.configure("/home/yml/myZopeInstances/sitePerso/etc/zope.conf") app = Zope.app()
You could do the work in a Script (Python) too, then you don't have to do this dance, or worry about managing transactions, conflict errors, and the rest for yourself...
I am not sure to understand the previous statement could you please be more explicit?
Your script is something you store on the filesystem and run from a shell prompt. That means you have to do all the ZODB setup work and management yourself. If you wrote a Script(Python) through the ZMI, it could do the same work but all the setup and ZODB management would be done for you by Zope's publisher.
-How can I list all the role available on an object?
from AccessControl import getSecurityManager getSecurityManager().getUser().getRolesInContext(object)
-How can I get the permissions list granted on an object?
Bwahahahaha ;-) from AccessControl.Permission import Permission from types import ListType result = [] for pstuff in object.ac_inherited_permissions(1): name,value = pstuff[:2] p = Permission(name,value,oject) groles = p.getRoles(default=[]) acquired = isinstance(groles,ListType) result.append({'permission':name,'roles':groles,'acquire':acquired)) Which will leave result somthing like:
print result [{'permission':'View','roles':['MyRole'],'acquire':1}]
- Which module should I import in my script in order to run your function?
for the original function: from AccessControl.Permission import Permission import types
- Is there somewhere a nice tutorial that will help me to be familiar with the ZOPE API?
Bwahahahhahahahaha - no. Sorry :-(
As I guess you noticed I am a newbie in the zope world so I am sorry asking stupid things
Don't worry, your questions point out some interesting gaps in current Zope docs and interfaces... Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk