[Zope-dev] LoginManager.

Terje Malmedal tm@funcom.com
Sun, 20 Aug 2000 23:53:48 +0200


Can anybody please provide a simple example of a working usersource
written in python?

I've written this, but it just does not work, all that happens is that
it writes opened to /tmp/source.log

class USER:
    "Just a little test"
    name    = None
    roles   = [ 'Anonymous' , 'member' ]
    domains = []

    def __init__(self, name):
        self.name = name

class SolidUserSource(BasicUserSource):

    """ Solid User Source """

    __plugin_kind__ = "User Source"
    meta_type       = "Solid User Source"
    f = open("/tmp/source.log",'a',0)
    f.write("opened\n")
    
    #def __init__(id,title):
    #    self.f.write("init %s %s\n" % (id,title))
    #    self.id = id
    #    self.title = title
        
    def existsUser(self, name):
        self.f.write('Users exists %s\n' % name)
        return 1

    def retreiveItem(self, name):

        self.f.write('Creating object for %s\n' % name)
        return USER(name)

    def rolesForUser(self, user):
        self.f.write('Returning roles for %s\n' % user.name)
        return user.roles

    def domainsForUser(self, user):
        self.f.write('Returning domains for %s\n' % user.name)
        return user.domains

    def authenticateUser(self, user, password, request):
        self.f.write('Authenticates user %s\n' % user.name)
        if user.name == 'aaa' and password == 'aaa':
            return 1 == 1
        return 1 == 0


-- 
 - Terje
tm@funcom.com