Adding a new UserSource
I am trying to add a new UserSource for LoginManager. I placed a directory SampleUserSource in /usr/lib/zope/lib/python/Products , in this directory I placed two files __init__.py and SampleUserSource.py . Here are the contents of the files: __init__.py: from SampleUserSource import SampleUserSource def initialize(context): ''' Register SampleUserSource class as a ZPatterns Plug-in''' context.registerPlugInClass( SampleUserSource, permission = 'Add Sample User Source', constructors = defaultConstructors(SampleUserSource, globals())) context.registerBaseClass(SampleUserSource) SampleUserSource.py: from Products.LoginManager.UserSources import BasicUserSource class SampleUserSource(BasicUserSource): """ Sample UserSource plugin """ meta_type = "Sample User Source" def retrieveItem(self, name): raise NotImplementedError def rolesForUser(self, user): raise NotImplementedError def domainsForUser(self, user): raise NotImplementedError def authenticateUser(self, user, password, request): raise NotImplementedError I restart Zope, but the new user source does not show up in the products list, nor does it show up in the list of available user sources. Obviously, I am missing something here either about making Python Products or plug-ins. If anyone could point out to me what I am doing wrong I would appreciate it. There are .pyc files in the SampleUserSource directory so I know Zope at least is aware of the files existence. -- Harry Henry Gebel, ICQ# 76308382 West Dover Hundred, Delaware
At 10:10 AM 10/15/00 -0400, Harry Henry Gebel wrote:
I am trying to add a new UserSource for LoginManager. I placed a directory SampleUserSource in /usr/lib/zope/lib/python/Products , in this directory I placed two files __init__.py and SampleUserSource.py . Here are the contents of the files:
__init__.py:
from SampleUserSource import SampleUserSource
def initialize(context): ''' Register SampleUserSource class as a ZPatterns Plug-in''' context.registerPlugInClass( SampleUserSource, permission = 'Add Sample User Source', constructors = defaultConstructors(SampleUserSource, globals()))
context.registerBaseClass(SampleUserSource)
You didn't import "defaultConstructors", so your code is erroring out during the initialize. Also, there is no reason to register the base class for your user source unless you plan to make a ZClass subclass of it, which isn't supported in any released version of ZPatterns. (0.4.3 will support ZClass subclasses of PlugIns and PlugInContainers, but you'll have to jump through slightly different hoops to make them work.)
participants (2)
-
Harry Henry Gebel -
Phillip J. Eby