At 11:53 PM 8/20/00 +0200, Terje Malmedal wrote:
>
>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

The above will not work, because UserSources *must* provide a user object
which subclasses from LoginUser.


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

Your retrieveItem isn't checking to see if the user exists.  Also, you
spelled it "retreive" when the correct spelling is "retrieve".


>    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

These methods never get called because the code that calls them is in the
LoginUser class, which you have not subclassed your user from.

You may want to consider simply configuring a GenericUserSource; you can
always use ExternalMethods to do so.  It is not so much that making a
custom user source is hard, as that it effectively requires an
understanding of how to subclass the ZPatterns "Rack" concept, and you may
not wish to expend that much effort simply to create a custom user source.
Once you've created a GUS that works as you wish, you can always subclass
GUS and hardwire your working methods into it, if your needs call for a
pure-python, quickly installable solution.


_______________________________________________
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )

Reply via email to