def test_id_clean(self):
        from Products.PlonePAS.utils import cleanId, decleanId

        a = [
            "asdfasdf",
            "asdf-asdf",
            "asdf--asdf",
            "asdf---asdf",
            "asdf----asdf",
            "asdf-----asdf",
            "asdf%asdf",
            "asdf%%asdf",
            "asdf%%%asdf",
            "asdf%%%%asdf",
            "asdf%%%%%asdf",
            "asdf-%asdf",
            "asdf%-asdf",
            "asdf-%-asdf",
            "asdf%-%asdf",
            "asdf--%asdf",
            "asdf%--asdf",
            "asdf--%-asdf",
            "asdf-%--asdf",
            "asdf--%--asdf",
            "asdf%-%asdf",
            "asdf%--%asdf",
            "asdf%---%asdf",
            "-asdf",
            "--asdf",
            "---asdf",
            "----asdf",
            "-----asdf",
            "asdf-",
            "asdf--",
            "asdf---",
            "asdf----",
            "asdf-----",
            "%asdf",
            "%%asdf",
            "%%%asdf",
            "%%%%asdf",
            "%%%%%asdf",
            "asdf%",
            "asdf%%",
            "asdf%%%",
            "asdf%%%%",
            "asdf%%%%%",
            "asdf\x00asdf",
        ]
        b = [cleanId(id) for id in a]
        c = [decleanId(id) for id in b]
        ac = zip(a, c)
        for aa, cc in ac:
            self.assertTrue(aa == cc)
        cleaned = cleanId(u"abc")
        self.assertEqual(cleaned, "abc")
        self.assertTrue(isinstance(cleaned, str))
        self.assertFalse(isinstance(cleaned, unicode))
 def test_id_clean(self):
     from Products.PlonePAS.utils import cleanId, decleanId
     a = [
         "asdfasdf",
         "asdf-asdf",
         "asdf--asdf",
         "asdf---asdf",
         "asdf----asdf",
         "asdf-----asdf",
         "asdf%asdf",
         "asdf%%asdf",
         "asdf%%%asdf",
         "asdf%%%%asdf",
         "asdf%%%%%asdf",
         "asdf-%asdf",
         "asdf%-asdf",
         "asdf-%-asdf",
         "asdf%-%asdf",
         "asdf--%asdf",
         "asdf%--asdf",
         "asdf--%-asdf",
         "asdf-%--asdf",
         "asdf--%--asdf",
         "asdf%-%asdf",
         "asdf%--%asdf",
         "asdf%---%asdf",
         "-asdf",
         "--asdf",
         "---asdf",
         "----asdf",
         "-----asdf",
         "asdf-",
         "asdf--",
         "asdf---",
         "asdf----",
         "asdf-----",
         "%asdf",
         "%%asdf",
         "%%%asdf",
         "%%%%asdf",
         "%%%%%asdf",
         "asdf%",
         "asdf%%",
         "asdf%%%",
         "asdf%%%%",
         "asdf%%%%%",
         "asdf\x00asdf",
     ]
     b = [cleanId(id) for id in a]
     c = [decleanId(id) for id in b]
     ac = zip(a, c)
     for aa, cc in ac:
         self.assertTrue(aa == cc)
     cleaned = cleanId(u'abc')
     self.assertEqual(cleaned, 'abc')
     self.assertTrue(isinstance(cleaned, str))
     if six.PY2:
         self.assertFalse(isinstance(cleaned, six.text_type))
예제 #3
0
 def test_id_clean(self):
     from Products.PlonePAS.utils import cleanId, decleanId
     a = [
          "asdfasdf",
          "asdf-asdf",
          "asdf--asdf",
          "asdf---asdf",
          "asdf----asdf",
          "asdf-----asdf",
          "asdf%asdf",
          "asdf%%asdf",
          "asdf%%%asdf",
          "asdf%%%%asdf",
          "asdf%%%%%asdf",
          "asdf-%asdf",
          "asdf%-asdf",
          "asdf-%-asdf",
          "asdf%-%asdf",
          "asdf--%asdf",
          "asdf%--asdf",
          "asdf--%-asdf",
          "asdf-%--asdf",
          "asdf--%--asdf",
          "asdf%-%asdf",
          "asdf%--%asdf",
          "asdf%---%asdf",
          "-asdf",
          "--asdf",
          "---asdf",
          "----asdf",
          "-----asdf",
          "asdf-",
          "asdf--",
          "asdf---",
          "asdf----",
          "asdf-----",
          "%asdf",
          "%%asdf",
          "%%%asdf",
          "%%%%asdf",
          "%%%%%asdf",
          "asdf%",
          "asdf%%",
          "asdf%%%",
          "asdf%%%%",
          "asdf%%%%%",
          "asdf\x00asdf",
     ]
     b = [cleanId(id) for id in a]
     c = [decleanId(id) for id in b]
     ac = zip(a, c)
     for aa, cc in ac:
         self.assertTrue(aa == cc)
예제 #4
0
 def test_id_clean(self):
     from Products.PlonePAS.utils import cleanId, decleanId
     a = [
         "asdfasdf",
         "asdf-asdf",
         "asdf--asdf",
         "asdf---asdf",
         "asdf----asdf",
         "asdf-----asdf",
         "asdf%asdf",
         "asdf%%asdf",
         "asdf%%%asdf",
         "asdf%%%%asdf",
         "asdf%%%%%asdf",
         "asdf-%asdf",
         "asdf%-asdf",
         "asdf-%-asdf",
         "asdf%-%asdf",
         "asdf--%asdf",
         "asdf%--asdf",
         "asdf--%-asdf",
         "asdf-%--asdf",
         "asdf--%--asdf",
         "asdf%-%asdf",
         "asdf%--%asdf",
         "asdf%---%asdf",
         "-asdf",
         "--asdf",
         "---asdf",
         "----asdf",
         "-----asdf",
         "asdf-",
         "asdf--",
         "asdf---",
         "asdf----",
         "asdf-----",
         "%asdf",
         "%%asdf",
         "%%%asdf",
         "%%%%asdf",
         "%%%%%asdf",
         "asdf%",
         "asdf%%",
         "asdf%%%",
         "asdf%%%%",
         "asdf%%%%%",
         "asdf\x00asdf",
     ]
     b = [cleanId(id) for id in a]
     c = [decleanId(id) for id in b]
     ac = zip(a, c)
     for aa, cc in ac:
         self.assertTrue(aa == cc)
예제 #5
0
def initializeAreas(pm_tool, acl_tool, request, member_folder_id=None):
    """
    Creates custom content in the member's folder.
    Create group spaces and content for those groups.
    
    1. Create private space for the user.
    2. Create public space for user if they are a member of parliament.
    3. Populate the public space with initial custom content.
    4. Create group home folder for any groups (except a parliament) this user is a member of.
        4.1 Create a private space for the group home folder.
        4.2 Create a public space for the group home folder
        4.3 Populate the groups public space with initial custom content.
    """
    portal = getSite()
    sm = getSecurityManager()

    tmp_user = BaseUnrestrictedUser(sm.getUser().getId(), '', ['Manager'], '')
    newSecurityManager(None, tmp_user)
    acl_tool = getToolByName(portal, 'acl_users')

    if "groups" in portal.objectIds():
        groups_space = portal["groups"]
    if member_folder_id:
        member = pm_tool.getMemberById(decleanId(member_folder_id))
    else:
        member = pm_tool.getAuthenticatedMember()
    member_id = member.getId()
    folder = pm_tool.getHomeFolder(member_id)

    #All members get a private workspace area.
    create_space(folder, "private_space", _(u"Private Space"), "private",
                 member_id, member, "PrivateFolder")

    member_groupIds = member.getGroupIds()
    for member_groupId in member_groupIds:
        group_membership_roles = doSearch(acl_tool, member_groupId)
        if "bungeni.MP" in group_membership_roles:
            create_space(folder, "web_space", _(u"Web Space"), "publish",
                         member_id, member, "PublicFolder")
            parent_space = getattr(folder, "web_space")
            mark(parent_space, IMemberSpace)
            create_content(parent_space, MEMBER_SPACE_CONTENT, member,
                           "publish")

    groups_space = portal["groups"]

    for member_groupId in member_groupIds:
        group_membership_roles = doSearch(acl_tool, member_groupId)
        #if group home folder does not exist
        #it is cheaper to check if the group home folder already exists, then exit if it does
        for bungeni_group in acl_tool.bungeni_groups.enumerateGroups():

            if (member_groupId == bungeni_group["id"]) and (
                    "bungeni.MP" not in group_membership_roles) and (
                        bungeni_group["id"] not in groups_space.objectIds()):
                group = acl_tool.bungeni_groups.getGroupById(
                    bungeni_group["id"])
                create_space(groups_space, bungeni_group["id"],
                             bungeni_group["title"], "private",
                             bungeni_group["id"], group, "Folder")
                parent_space = getattr(groups_space, bungeni_group["id"])
                create_space(parent_space, "private_space",
                             _u("Private Space"), "private",
                             bungeni_group["id"], group, "PrivateFolder")
                create_space(parent_space, "web_space", _(u"Web Space"),
                             "publish", bungeni_group["id"], group,
                             "PublicFolder")
                parent_space = getattr(parent_space, "web_space")
                mark(parent_space, IGroupSpace)
                create_content(parent_space, GROUP_SPACE_CONTENT, group,
                               "publish")
예제 #6
0
def initializeAreas(pm_tool, acl_tool, request, member_folder_id=None):
    """
    Creates custom content in the member's folder.
    Create group spaces and content for the member's groups.
    
    1. Create private space for the user.
    2. Create public space for user if they are a member of parliament.
    3. Populate the public space with custom content
    4. Create group home folder for any groups (except a parliament) this user is a member of.
        3.1 Create a private space for the group home folder.
        3.2 Create a public space for the group home folder
        3.3 Populate the public space with custom content.
    """
    portal = getSite()
    sm = getSecurityManager()

    tmp_user = BaseUnrestrictedUser(sm.getUser().getId(),'', ['Manager'],'')
    newSecurityManager(None, tmp_user)    
    acl_tool = getToolByName(portal, 'acl_users')
    
    if "groups" in portal.objectIds():
        groups_space = portal["groups"]
    if member_folder_id:
        member = pm_tool.getMemberById(decleanId(member_folder_id))
    else:
        member = pm_tool.getAuthenticatedMember()
    member_id = member.getId()
    folder = pm_tool.getHomeFolder(member_id)
         
    #All members get a private workspace area.
    create_space(folder, "private_space", "Private Space", "private", member_id, member, "PrivateFolder")   
    member_groupIds = member.getGroupIds()
    for member_groupId in member_groupIds:
        group_membership_roles = doSearch(acl_tool, member_groupId)
        if "bungeni.MP" in group_membership_roles:
            create_space(folder, "web_space", "Web Space", "publish", member_id, member, "PublicFolder")
            parent_space = getattr(folder, "web_space")
            mark(parent_space, IMemberSpace)    
            parent_space.setLayout("space_view")  
            create_content(parent_space, MEMBER_SPACE_CONTENT, member, "publish")


    groups_space = portal["groups"]

    for member_groupId in member_groupIds:
        group_membership_roles = doSearch(acl_tool, member_groupId)
        #if group home folder does not exist
        #it is cheaper to check if the group home folder already exists, then exit if it does
        for bungeni_group in acl_tool.bungeni_groups.enumerateGroups():

            if (member_groupId == bungeni_group["id"]) and ("bungeni.MP" not in group_membership_roles) and (bungeni_group["id"]not in groups_space.objectIds()):
                group = acl_tool.bungeni_groups.getGroupById(bungeni_group["id"])                 
                create_space(groups_space, bungeni_group["id"],
                    bungeni_group["title"], "private", bungeni_group["id"], 
                    group, "Folder")
                parent_space = getattr(groups_space, bungeni_group["id"])               
                create_space(parent_space, "private_space", "Private Space", 
                    "private", bungeni_group["id"], 
                    group, "PrivateFolder")                       
                create_space(parent_space, "web_space", "Web Space", 
                    "publish", bungeni_group["id"], 
                     group, "PublicFolder") 
                parent_space = getattr(parent_space, "web_space")
                mark(parent_space, IGroupSpace)  
                parent_space.setLayout("space_view")
                create_content(parent_space, GROUP_SPACE_CONTENT, group, "publish")