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
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
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
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]
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]
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
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]
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 )
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]
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
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)
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
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