示例#1
0
    def _get_group_by_info(self, info):
        if info is None:
            return None
        group = PloneGroup(info['id'], info['id']).__of__(self)
        pas = self._getPAS()
        plugins = pas.plugins

        # add properties
        # 1.) shortcut to own properties
        data = self._get_propertysheet_of_info(info)
        group.addPropertysheet(self.getId(), data)

        properties_provider = plugins.listPlugins(
            pas_interfaces.IPropertiesPlugin)

        # 2.) other possible plugins
        for propfinder_id, propfinder in properties_provider:
            if propfinder_id == self.getId():
                continue
            data = propfinder.getPropertiesForUser(group, None)
            if not data:
                continue
            group.addPropertysheet(propfinder_id, data)

        # add subgroups
        group._addGroups(
            pas._getGroupsForPrincipal(group, None, plugins=plugins))
        # add roles
        role_provider = plugins.listPlugins(pas_interfaces.IRolesPlugin)
        for rolemaker_id, rolemaker in role_provider:
            roles = rolemaker.getRolesForPrincipal(group, None)
            if not roles:
                continue
            group._addRoles(roles)
        return group
示例#2
0
    def getGroupById(self, group_id):
        """
        Returns the portal_groupdata-ish object for a group
        corresponding to this id.
        """

        if group_id and self.enumerateGroups(group_id):
            group = PloneGroup(group_id, None)
            plugins = self._getPAS()._getOb('plugins')
            propfinders = plugins.listPlugins(IPropertiesPlugin)
            for propfinder_id, propfinder in propfinders:

                data = propfinder.getPropertiesForUser(group, request=None)
                if data:
                    group.addPropertysheet(propfinder_id, data)

            groups = self._getPAS()._getGroupsForPrincipal(
                group, request=None, plugins=plugins)
            group._addGroups(groups)

            rolemakers = plugins.listPlugins(IRolesPlugin)

            for rolemaker_id, rolemaker in rolemakers:
                roles = rolemaker.getRolesForPrincipal(group, request=None)
                if roles:
                    group._addRoles(roles)

            group._addRoles(['Authenticated'])

            return group.__of__(self)
        else:
            return None
    def getGroupById(self, groupid, default=None):

        group = PloneGroup(groupid)
        group = group.__of__(self)
        
        # add UserPropertySheet with title
        # We assume the title is the same as the id
        data = {'title': groupid}
        group.addPropertysheet(self.getId(), data)

        return group
示例#4
0
    def getGroupById(self, group_id):
        """
        Returns the portal_groupdata-ish object for a group
        corresponding to this id. None if group does not exist here!
        """
        groups = self.groups
        if not groups or group_id not in self.getGroupIds():
            return None
        ugmgroup = self.groups[group_id]
        title = ugmgroup.attrs.get('title', None)
        group = PloneGroup(ugmgroup.id, title).__of__(self)
        pas = self._getPAS()
        plugins = pas.plugins
        # add properties
        for propfinder_id, propfinder in \
                plugins.listPlugins(pas_interfaces.IPropertiesPlugin):

            data = propfinder.getPropertiesForUser(group, None)
            if not data:
                continue
            group.addPropertysheet(propfinder_id, decode(data))
        # add subgroups
        group._addGroups(
            pas._getGroupsForPrincipal(group, None, plugins=plugins))
        # add roles
        for rolemaker_id, rolemaker in \
                plugins.listPlugins(pas_interfaces.IRolesPlugin):

            roles = rolemaker.getRolesForPrincipal(group, None)
            if not roles:
                continue
            group._addRoles(roles)
        return group
示例#5
0
    def getGroups(self):
        """
        Returns an iteration of the available groups
        """

        session = Session()
        groups = session.query(self.group_class).all()
        return [PloneGroup(g.zope_id).__of__(self) for g in groups]
示例#6
0
文件: plugin.py 项目: cklit/fritzing
    def getGroups(self):
        """
        Returns an iteration of the available groups
        """

        session = Session()
        groups = session.query(model.Group).all()
        return [PloneGroup(g.name).__of__(self) for g in groups]
示例#7
0
    def getGroupById(self, group_id):
        """
        Returns the portal_groupdata-ish object for a group
        corresponding to this id. None if group does not exist here!
        """
        group_id = decode_utf8(group_id)
        groups = self.groups
        if not groups or group_id not in groups.keys():
            return None
        ugmgroup = self.groups[group_id]
        title = ugmgroup.attrs.get("title", None)
        group = PloneGroup(ugmgroup.id, title).__of__(self)
        pas = self._getPAS()
        plugins = pas.plugins
        # add properties
        for propfinder_id, propfinder in plugins.listPlugins(pas_interfaces.IPropertiesPlugin):

            data = propfinder.getPropertiesForUser(group, None)
            if not data:
                continue
            group.addPropertysheet(propfinder_id, data)
        # add subgroups
        group._addGroups(pas._getGroupsForPrincipal(group, None, plugins=plugins))
        # add roles
        for rolemaker_id, rolemaker in plugins.listPlugins(pas_interfaces.IRolesPlugin):

            roles = rolemaker.getRolesForPrincipal(group, None)
            if not roles:
                continue
            group._addRoles(roles)
        return group
示例#8
0
 def getGroups(self):
     """
     Returns an iteration of the available groups
     """
     http_obj=httplib2.Http()
     query = "/++rest++brs/groups"
     resp,content = http_obj.request(connection_url() + query, "GET")
     groups = simplejson.loads(content)
     return [PloneGroup(r).__of__(self) for r in groups]
示例#9
0
 def getGroupById(self, group_id):
     """
     Returns the portal_groupdata-ish object for a group
     corresponding to this id.
     """
     gid = self._gid( group_id )
     if not gid:
         return None
     return PloneGroup(gid).__of__( self )
示例#10
0
    def getGroups(self):
        """
        Returns an iteration of the available groups
        """

        session = Session()
        groups = session.query(
            domain.Group).filter(domain.Group.status == 'active').all()
        return [PloneGroup(r.group_principal_id).__of__(self) for r in groups]
示例#11
0
    def getGroupById(self, group_id):
        """
        Returns the portal_groupdata-ish object for a group
        corresponding to this id.
        """

        if group_id and self.enumerateGroups(group_id):
            group = PloneGroup(group_id, None)

            for name, data in self._get_properties_for_user_from_pas(group):
                group.addPropertysheet(name, data)

            for roles in self._get_roles_for_principal_from_pas(group):
                group._addRoles(roles)

            for groups in self._get_groups_for_principal_from_pas(group):
                group._addGroups(groups)

            group._addRoles(['Authenticated'])

            return group.__of__(self)
        else:
            return None
示例#12
0
    def _createGroup(self, plugins, group_id, name):
        """ Create group object. For users, this can be done with a
        plugin, but I don't care to define one for that now. Just uses
        PloneGroup.  But, the code's still here, just commented out.
        This method based on PluggableAuthervice._createUser
        """

        #factories = plugins.listPlugins(IUserFactoryPlugin)

        #for factory_id, factory in factories:

        #    user = factory.createUser(user_id, name)

        #    if user is not None:
        #        return user.__of__(self)

        return PloneGroup(group_id, name).__of__(self)
示例#13
0
    def getGroupById(self, group_id):
        """
        Returns the portal_groupdata-ish object for a group
        corresponding to this id. None if group does not exist here!
        """
        default = None
        if not self.is_plugin_active(
                plonepas_interfaces.group.IGroupIntrospection):
            return default
        if group_id is None:
            return None
        if not isinstance(group_id, six.text_type):
            group_id = group_id.decode("utf8")
        groups = self.groups
        if not groups or group_id not in list(groups.keys()):
            return default
        ugmgroup = self.groups[group_id]
        title = ugmgroup.attrs.get("title", None)
        group = PloneGroup(ugmgroup.id, title).__of__(self)
        pas = self._getPAS()
        plugins = pas.plugins
        # add properties
        for propfinder_id, propfinder in plugins.listPlugins(
                pas_interfaces.IPropertiesPlugin):

            data = propfinder.getPropertiesForUser(group, None)
            if not data:
                continue
            group.addPropertysheet(propfinder_id, data)
        # add subgroups
        group._addGroups(
            pas._getGroupsForPrincipal(group, None, plugins=plugins))
        # add roles
        for rolemaker_id, rolemaker in plugins.listPlugins(
                pas_interfaces.IRolesPlugin):

            roles = rolemaker.getRolesForPrincipal(group, None)
            if not roles:
                continue
            group._addRoles(roles)
        return group
示例#14
0
    def getGroupById(self, group_id):
        """
        Returns the portal_groupdata-ish object for a group
        corresponding to this id.
        """

        if group_id and self.enumerateGroups(group_id):
            group = PloneGroup(group_id, None)

            for name, data in self._get_properties_for_user_from_pas(group):
                group.addPropertysheet(name, data)

            for roles in self._get_roles_for_principal_from_pas(group):
                group._addRoles(roles)

            for groups in self._get_groups_for_principal_from_pas(group):
                group._addGroups(groups)

            group._addRoles(['Authenticated'])

            return group.__of__(self)
        else:
            return None
示例#15
0
文件: plugin.py 项目: cklit/fritzing
    def getGroupById(self, group_id):
        """
        Returns the portal_groupdata-ish object for a group
        corresponding to this id.
        """

        if group_id and self.enumerateGroups(group_id):
            group = PloneGroup(group_id, None)
            plugins = self._getPAS()._getOb('plugins')
            propfinders = plugins.listPlugins(IPropertiesPlugin)
            for propfinder_id, propfinder in propfinders:

                data = propfinder.getPropertiesForUser(group, request=None)
                if data:
                    group.addPropertysheet(propfinder_id, data)

            groups = self._getPAS()._getGroupsForPrincipal(group,
                                                           request=None,
                                                           plugins=plugins)
            group._addGroups(groups)

            rolemakers = plugins.listPlugins(IRolesPlugin)

            for rolemaker_id, rolemaker in rolemakers:
                roles = rolemaker.getRolesForPrincipal(group, request=None)
                if roles:
                    group._addRoles(roles)

            group._addRoles(['Authenticated'])

            return group.__of__(self)
        else:
            return None