[Checkins] SVN: Sandbox/ulif/megrok.login/src/megrok/login/grokker.py Add grokkers.

Uli Fouquet uli at gnufix.de
Fri Dec 5 19:16:02 EST 2008


Log message for revision 93706:
  Add grokkers.

Changed:
  A   Sandbox/ulif/megrok.login/src/megrok/login/grokker.py

-=-
Added: Sandbox/ulif/megrok.login/src/megrok/login/grokker.py
===================================================================
--- Sandbox/ulif/megrok.login/src/megrok/login/grokker.py	                        (rev 0)
+++ Sandbox/ulif/megrok.login/src/megrok/login/grokker.py	2008-12-06 00:16:01 UTC (rev 93706)
@@ -0,0 +1,41 @@
+import martian
+import grok
+import megrok.login
+from zope import component
+
+from zope.app.authentication import PluggableAuthentication
+from zope.app.authentication.principalfolder import PrincipalFolder
+from zope.app.authentication.session import SessionCredentialsPlugin
+from zope.app.security.interfaces import IAuthentication
+
+class ApplicationGrokker(martian.ClassGrokker):
+    martian.component(grok.Site)
+    martian.priority(100)
+    martian.directive(megrok.login.enable, default=False)
+    martian.directive(megrok.login.viewname, default=u'loginForm.html')
+
+    def execute(self, factory, config, enable, viewname, **kw):
+        if enable is False:
+            return False
+        adapts = (factory, grok.IObjectAddedEvent)
+        config.action(
+            discriminator=None,
+            callable=component.provideHandler,
+            args=(authenticationSubscriber, adapts)
+            )
+        return True
+
+def authenticationSubscriber(site, event):
+    grok.meta.setupUtility(site, PluggableAuthentication(),
+                      IAuthentication, setup=setupPAU)
+
+def setupPAU(pau):
+    """Callback to setup the Pluggable Authentication Utility """
+    pau['principals'] = PrincipalFolder() 
+    pau.authenticatorPlugins = ('principals',)
+    pau['session'] = session = SessionCredentialsPlugin()
+    pau.credentialsPlugins = ('No Challenge if Authenticated', 'session',)
+    site = pau.__parent__.__parent__
+    viewname = megrok.login.component.viewname.bind().get(site)
+    session.loginpagename = viewname
+



More information about the Checkins mailing list