Hello,

I have to upgrade for plone 3 a script written some years ago for the
GrufSpace product.

The script connects to a ldap server, fetches some groups and builds
groupspaces and sets ths correct roles in order for a member of the
ldap group to get a default role on related groupspace.

The script is run from the ZMI, connected as "admin", by clicking on
the 'Test' tab of the script.

Here's the content of the script :

===================================================
# Import a standard function, and get the HTML request and response objects.
from Products.PythonScripts.standard import html_quote


request = container.REQUEST
RESPONSE =  request.RESPONSE

# Return a string identifying this script.
print "This is the", script.meta_type, '"%s"' % script.getId(),
if script.title:
    print "(%s)" % html_quote(script.title),
print "in", container.absolute_url()

# Definition des groupes pour lesquels on veut creer un grufspace :

from Products.CMFCore.utils import getToolByName
gtool = getToolByName(context, 'portal_groups')
pt = getToolByName(context, 'portal_types')
url_tool = getToolByName(context, 'portal_url')
portal = url_tool.getPortalObject()
acl = portal.acl_users
groups = portal.groups
groupspace_ids = groups.objectIds()

# Recherche des groupes existant dans l'annuaire LDAP
# lgrps : ensemble des cn des groupes trouves dans ldap
# lgrpDetails : details de chaque groupe
# member : dn de chaque membre du groupe en cours de traitement
#acl_users.GrufBridge.acl_users.Users02.acl_users
#acl_users.GrufBridge.acl_users.Groups.acl_users



lgrps = [g[0] for g in acl.suppann.acl_users.getGroups()]


for lgrp in lgrps:
    st = lgrp.startswith
    if not (st('college_') or st('pe2_') or st('plc2_') or st('cpe_')):
        continue

    print lgrp, ":",

    if lgrp not in groupspace_ids:
        # Add GroupSpace if possible
        print "groupspace created",
        try:
            pt.constructContent('GroupSpace', groups, id=lgrp, title=lgrp)
            groupspace_ids.append(lgrp)
        except:
            raise
    print
    # Verifier si le groupe Zope est GroupMember dans le GroupSpace
    # Si ce n'est pas le cas, l'ajouter
    my_group = getattr(groups, lgrp)

    group_roles = {'delegate_admin_group': ['GroupAdmin',],
                    }

    my_group.group_roles = PersistentMapping()

    my_group.group_roles.update(group_roles)
    my_group.reindexObject()
    my_group.assignCollabRoleToGroup("GroupContributor", lgrp)


return printed

======================================================================



This script gives the error : "NameError: global name
'PersistentMapping' is not defined " (see end of script)

I tried to add this at the beginning : "from Globals import PersistentMapping"
But then, I got a message saying Insuficient privileges.

Would someone have an idea of what to do to solve this privilege problem ?

Best regards,

-- 
Mikael Kermorgant
_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers

Reply via email to