Re: [Zope3-Users] Programatically add plugins to PAU
Florian Lindner wrote: Am Mittwoch, 12. April 2006 08:39 schrieb Michael Howitz: reg = site.UtilityRegistration(name, interface, utility) Thanks for the code. One question: Of what type is site? Sorry i forgot one import: from zope.app.component import site -- Mit freundlichen Grüßen Michael Howitz gocept gmbh & co. kg · forsterstrasse 29 · 06112 halle/saale www.gocept.com · fon: +49 345 12298898 · fax: +49 345 12298891 ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Programatically add plugins to PAU
Am Mittwoch, 12. April 2006 08:39 schrieb Michael Howitz: > Florian Lindner wrote: > > Hello, > > I've a PluggableAuthentication and want to add and register some plugins > > to it. > > > > Adding works fine: > > > > principal_folder = > > zope.app.authentication.principalfolder.PrincipalFolder(prefix = "cs") > > > > pau["PrincipalFolder"] = principal_folder > > > > and I think I can select it with: > > > > pau.credentialsPlugins = [principal_folder] > > > > but how to register it before? > > > > And how do I select credential plugins? > > This is how we did it in a project: > createAuthenticationUtils is called on handling the ObjectAddedEvent for > the folder (which is programmatically made a site) which should contain > the PAU. > reg = site.UtilityRegistration(name, interface, utility) Thanks for the code. One question: Of what type is site? Thanks, Florian ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Programatically add plugins to PAU
Am Mittwoch, 12. April 2006 08:50 schrieb Stephan Richter: > On Wednesday 12 April 2006 02:39, Michael Howitz wrote: > > This is how we did it in a project: > > createAuthenticationUtils is called on handling the ObjectAddedEvent for > > the folder (which is programmatically made a site) which should contain > > the PAU. > > Interesting. We did, of course, something similar too in our current > project. This either means that (a) PAU is too hard to set up and/or (b) > that we need another "helper" layer. > > I would like to think the problem is (b), because I like the flexibility of > PAU. The configuration package we wrote is step one, but it would be good > to agree on a set of high-level helper functions too. I think it's fine the way it is beside one thing. # This is fine, it's added just like all the other utilites. pau = ensureUtility(cs, IPluggableAuthentication, '', PluggableAuthentication , asObject = True) # This is ok for adding, but I got no idea how to register it. A nice thing would be function like ensurePlugin that works analog to ensureUtility (adds und registers a plugin, does the NameChooser call if needed, ...) principal_folder = PrincipalFolder(prefix = "cs") pau["PrincipalFolder"] = principal_folder # This is pretty straightforward but I was not expecting to give a string, rather I thougt it expected a Interface or something like that. pau.credentialsPlugins = (u'Session Credentials',) The only thing I would change is to add a ensurePlugin function to either the pau object itself or also as part of zope.app.appsetup. (like all the other ensure* functions). Florian ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Programatically add plugins to PAU
On Wednesday 12 April 2006 02:39, Michael Howitz wrote: > This is how we did it in a project: > createAuthenticationUtils is called on handling the ObjectAddedEvent for > the folder (which is programmatically made a site) which should contain > the PAU. Interesting. We did, of course, something similar too in our current project. This either means that (a) PAU is too hard to set up and/or (b) that we need another "helper" layer. I would like to think the problem is (b), because I like the flexibility of PAU. The configuration package we wrote is step one, but it would be good to agree on a set of high-level helper functions too. Regards, Stephan -- Stephan Richter CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Programatically add plugins to PAU
Florian Lindner wrote: Hello, I've a PluggableAuthentication and want to add and register some plugins to it. Adding works fine: principal_folder = zope.app.authentication.principalfolder.PrincipalFolder(prefix = "cs") pau["PrincipalFolder"] = principal_folder and I think I can select it with: pau.credentialsPlugins = [principal_folder] but how to register it before? And how do I select credential plugins? This is how we did it in a project: createAuthenticationUtils is called on handling the ObjectAddedEvent for the folder (which is programmatically made a site) which should contain the PAU. HTH, mac --- from zope.app.security.interfaces import IAuthentication from zope.app.authentication.interfaces import IAuthenticatorPlugin from zope.app.appsetup.bootstrap import ensureUtility from zope.app.authentication.authentication import \ PluggableAuthentication from zope.app.authentication.principalfolder import PrincipalFolder from zope.app.authentication.groupfolder import \ GroupFolder, GroupInformation from zope.app import zapi from myproject import config def addUtilityToPAU(pau, interface, utility_factory, id, name): utility = utility_factory() pau[id] = utility reg_man = pau.registrationManager reg = site.UtilityRegistration(name, interface, utility) reg_man.addRegistration(reg) reg.status = u'Active' def _addGroupInformation(group_folder, id, title, description): group = GroupInformation() group.title = title group.description = description group_folder[id] = group def createAuthenticationUtils(obj): ensureUtility(obj, IAuthentication, '', PluggableAuthentication, copy_to_zlog=False) auth = zapi.getUtility(IAuthentication) auth.credentialsPlugins = (u'Session Credentials',) addUtilityToPAU(auth, IAuthenticatorPlugin, PrincipalFolder, 'principal_folder', u'Benutzerverwaltung') addUtilityToPAU(auth, IAuthenticatorPlugin, GroupFolder, 'group_folder', u'Rollenverwaltung') auth.authenticatorPlugins = (u'Benutzerverwaltung', u'Rollenverwaltung',) group_folder = auth['group_folder'] for group in config.company_groups: _addGroupInformation(group_folder, group['id'], group['title'], group['description']) ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Programatically add plugins to PAU
Hello, I've a PluggableAuthentication and want to add and register some plugins to it. Adding works fine: principal_folder = zope.app.authentication.principalfolder.PrincipalFolder(prefix = "cs") pau["PrincipalFolder"] = principal_folder and I think I can select it with: pau.credentialsPlugins = [principal_folder] but how to register it before? And how do I select credential plugins? Thanks, Florian ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users