[Zope-PTK] Membership and loacl roles

Michael Bernstein mbernstein@profitscape.com
Fri, 15 Sep 2000 13:20:44 -0500


Hello all,

I feel that a barrier to Loginmanager and Membership becoming more
generally usable for site builders is it's current lack of support for
local roles. Specifically, members do not show up in the local roles
screen (manage_listLocalRoles) user list.

Through the magic of grep and find, I think I've identified the relevant
sections of code in Zope that need to be duplicated in Membership (or
maybe in LoginManager).

First I tracked down what seems to be the relevant section in
/lib/AccessControl/Role.py, in the section labeled 'Local roles
support':


    def get_valid_userids(self):
        item=self
        dict={}
        while 1:
            if hasattr(aq_base(item), 'acl_users') and \
               hasattr(item.acl_users, 'user_names'):
                for name in item.acl_users.user_names():
                    dict[name]=1
            if not hasattr(item, 'aq_parent'):
                break
            item=item.aq_parent
        keys=dict.keys()
        keys.sort()
        return keys


Then I tracked down the user_names attribute to
/lib/AccessControl/User.py, in the section labeled 'Private UserFolder
object interface':


    def user_names(self):
        return self.getUserNames()


Well, that wasn't very helpful. serching a bit more and I find:


    def getUserNames(self):
        """Return a list of usernames"""
        names=self.data.keys()
        names.sort()
        return names


Experimenting a bit, I find that a normal user folder object responds to
a /acl_users/user_names URL with an error, but does respond to a
/acl_users/getUserNames URL with a list of user names.

And now I'm stuck. I *think* that LoginManager needs a getUserNames
method that goes through the available User Sources and grabs a list of
names from each, concatenating them into one big list to return.

However, IANAC (I Am Not A Coder), and I don't know how to do this. If
anyone can offer a cut-and-paste set of instructions to add this into
Loginmanager or Membership, it would be greatly appreciated.

Thanks,

Michael Bernstein.