[Zope3-checkins] SVN: ldapauth/trunk/ Rename all views, adapters and interface for to test the LDAP connection to "check...". This way we don't mixup the naming with the real test stuff

Roger Ineichen roger at projekt01.ch
Tue Jul 20 20:38:02 EDT 2004


Log message for revision 26645:
  Rename all views, adapters and interface for to test the LDAP connection to "check...". This way we don't mixup the naming with the real test stuff


Changed:
  A   ldapauth/trunk/browser/check.pt
  A   ldapauth/trunk/browser/check.py
  D   ldapauth/trunk/browser/checkconnection.pt
  D   ldapauth/trunk/browser/checkconnection.py
  U   ldapauth/trunk/browser/configure.zcml
  A   ldapauth/trunk/check.py
  U   ldapauth/trunk/configure.zcml
  D   ldapauth/trunk/connectiontest.py
  U   ldapauth/trunk/interfaces.py


-=-
Copied: ldapauth/trunk/browser/check.pt (from rev 26644, ldapauth/trunk/browser/checkconnection.pt)

Copied: ldapauth/trunk/browser/check.py (from rev 26644, ldapauth/trunk/browser/checkconnection.py)
===================================================================
--- ldapauth/trunk/browser/checkconnection.py	2004-07-21 00:26:29 UTC (rev 26644)
+++ ldapauth/trunk/browser/check.py	2004-07-21 00:38:02 UTC (rev 26645)
@@ -0,0 +1,82 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""View Class for the Container's Contents view.
+
+$Id: contents.py 25177 2004-06-02 13:17:31Z jim $
+"""
+
+from zope.exceptions import NotFoundError
+
+from zope.app import zapi
+from zope.app.size.interfaces import ISized
+from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
+from zope.app.publisher.browser import BrowserView
+from zope.app.i18n import ZopeMessageIDFactory as _
+
+from ldapauth.interfaces import ILDAPBasedPrincipalSource
+from ldapauth.interfaces import ICheckLDAPAdapter
+
+
+
+class CheckLDAPView(BrowserView):
+
+    __used_for__ = ILDAPBasedPrincipalSource
+
+
+    def __init__(self, context, request):
+        self.context = context
+        self.request = request
+        self.__parent__ = context
+        self.report = []
+
+    def getHostInfo(self):
+        """Returns a dict with host information."""
+        infoDict = {}
+        infoDict['host'] = self.context.host
+        infoDict['port'] = self.context.port
+        infoDict['basedn'] = self.context.basedn
+        infoDict['login_attribute'] = self.context.login_attribute
+        infoDict['manager_dn'] = self.context.manager_dn
+        return infoDict
+
+
+    def checkConnection(self):
+        """Check connetction to the given LDAP server."""
+        runtest = self.request.get('runtest', None)
+        if runtest == "Run":
+            un = self.request.get('username')
+            pw = self.request.get('password')
+
+            # test the connection to the LDAP server
+            self._addInfo("<strong>Test LDAP server connection</strong>")
+            testadapter = ICheckLDAPAdapter(self.context)
+            self.report = self.report + testadapter.testConnection()
+
+            # test quering the LDAP server
+
+            # test query the given username
+
+            # test authenticate the given username
+
+            self._addInfo("... more test")
+    
+            return self.report
+        else:
+            return ""
+
+    def _addInfo(self, res):
+        """Add traceback info to the report list"""
+        self.report.append(res)
+
+    check = ViewPageTemplateFile('check.pt')

Deleted: ldapauth/trunk/browser/checkconnection.pt
===================================================================
--- ldapauth/trunk/browser/checkconnection.pt	2004-07-21 00:26:29 UTC (rev 26644)
+++ ldapauth/trunk/browser/checkconnection.pt	2004-07-21 00:38:02 UTC (rev 26645)
@@ -1,89 +0,0 @@
-<html metal:use-macro="views/standard_macros/view">
-<body>
-<div metal:fill-slot="body">
-  <div metal:define-macro="contents"
-			 tal:define="hostinfo view/getHostInfo;
-			 						 testreport view/checkConnection">
-
-		<form name="ldapConnectionTestForm" method="POST" action="."
-          tal:attributes="action request/URL">
-
-			<table id="sortable" class="listing" summary="LDAP Configuration listing"
-						 i18n:attributes="summary">
-				<thead>
-					<tr>
-						<th i18n:translate="">Desription</th>
-						<th i18n:translate="">Data</th>
-					</tr>
-				</thead>
-				<tbody>
-					<tr>
-						<td i18n:translate="">Hostname</td>
-						<td><span tal:content="python:hostinfo['host']">host</span></td>
-					</tr>
-					<tr>
-						<td i18n:translate="">Port</td>
-						<td><span tal:content="python:hostinfo['port']">port</span></td>
-					</tr>
-					<tr>
-						<td i18n:translate="">Login attribute name</td>
-						<td><span tal:content="python:hostinfo['login_attribute']">login_attribute</span></td>
-					</tr>
-					<tr>
-						<td i18n:translate="">Base DN</td>
-						<td><span tal:content="python:hostinfo['basedn']">basedn</span></td>
-					</tr>
-					<tr>
-						<td i18n:translate="">Manager DN</td>
-						<td><span tal:content="python:hostinfo['manager_dn']">manager_dn</span></td>
-					</tr>
-				</tbody>
-			</table>
-
-			<span i18n:translate="">
-				For to test the authentication, you can set a username and password.<br /> 
-				This usename and password has to be falid on the LDAP server.
-			</span>
-
-			<table id="sortable" class="listing" summary="LDAP Connection Test Data"
-						 i18n:attributes="summary">
-				<thead>
-					<tr>
-						<th i18n:translate="">Description</th>
-						<th i18n:translate="">Data</th>
-					</tr>
-				</thead>
-				<tbody>
-					<tr>
-						<td i18n:translate="">Username (optional)</td>
-						<td><input type="text" value="" name="username"></td>
-					</tr>
-					<tr>
-						<td i18n:translate="">Password (optional)</td>
-						<td><input type="password" value="" name="password"></td>
-					</tr>
-				</tbody>
-			</table>
-			<input type="hidden" value="Run" name="runtest">
-			<input type="submit" value="Test" name="submit">
-	
-			<table id="sortable" class="listing" summary="LDAP Connection Report listing"
-						 i18n:attributes="summary"
-						 tal:condition="testreport">
-				<thead>
-					<tr>
-						<th i18n:translate="">Test report</th>
-					</tr>
-				</thead>
-				<tbody>
-					<tr tal:repeat="line testreport" >
-						<td><span tal:content="structure line">report entry</span></td>
-					</tr>
-				</tbody>
-			</table>
-
-		</form>
-  </div>
-</div>
-</body>
-</html>

Deleted: ldapauth/trunk/browser/checkconnection.py
===================================================================
--- ldapauth/trunk/browser/checkconnection.py	2004-07-21 00:26:29 UTC (rev 26644)
+++ ldapauth/trunk/browser/checkconnection.py	2004-07-21 00:38:02 UTC (rev 26645)
@@ -1,82 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""View Class for the Container's Contents view.
-
-$Id: contents.py 25177 2004-06-02 13:17:31Z jim $
-"""
-
-from zope.exceptions import NotFoundError
-
-from zope.app import zapi
-from zope.app.size.interfaces import ISized
-from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
-from zope.app.publisher.browser import BrowserView
-from zope.app.i18n import ZopeMessageIDFactory as _
-
-from ldapauth.interfaces import ILDAPBasedPrincipalSource
-from ldapauth.interfaces import ILDAPTestAdapter
-
-
-
-class CheckConnectionView(BrowserView):
-
-    __used_for__ = ILDAPBasedPrincipalSource
-
-
-    def __init__(self, context, request):
-        self.context = context
-        self.request = request
-        self.__parent__ = context
-        self.report = []
-
-    def getHostInfo(self):
-        """Returns a dict with host information."""
-        infoDict = {}
-        infoDict['host'] = self.context.host
-        infoDict['port'] = self.context.port
-        infoDict['basedn'] = self.context.basedn
-        infoDict['login_attribute'] = self.context.login_attribute
-        infoDict['manager_dn'] = self.context.manager_dn
-        return infoDict
-
-
-    def checkConnection(self):
-        """Check connetction to the given LDAP server."""
-        runtest = self.request.get('runtest', None)
-        if runtest == "Run":
-            un = self.request.get('username')
-            pw = self.request.get('password')
-
-            # test the connection to the LDAP server
-            self._addInfo("<strong>Test LDAP server connection</strong>")
-            testadapter = ILDAPTestAdapter(self.context)
-            self.report = self.report + testadapter.testConnection()
-
-            # test quering the LDAP server
-
-            # test query the given username
-
-            # test authenticate the given username
-
-            self._addInfo("... more test")
-    
-            return self.report
-        else:
-            return ""
-
-    def _addInfo(self, res):
-        """Add traceback info to the report list"""
-        self.report.append(res)
-
-    check = ViewPageTemplateFile('checkconnection.pt')

Modified: ldapauth/trunk/browser/configure.zcml
===================================================================
--- ldapauth/trunk/browser/configure.zcml	2004-07-21 00:26:29 UTC (rev 26644)
+++ ldapauth/trunk/browser/configure.zcml	2004-07-21 00:38:02 UTC (rev 26645)
@@ -36,9 +36,9 @@
     <!-- connetion test view -->
     <page
         for="ldapauth.interfaces.ILDAPBasedPrincipalSource"
-        name="checkconnection.html"
+        name="check.html"
         attribute="check"
-        class=".checkconnection.CheckConnectionView"
+        class=".check.CheckLDAPView"
         menu="zmi_views" title="Test"
         permission="zope.ManageServices"/>
 

Copied: ldapauth/trunk/check.py (from rev 26644, ldapauth/trunk/connectiontest.py)
===================================================================
--- ldapauth/trunk/connectiontest.py	2004-07-21 00:26:29 UTC (rev 26644)
+++ ldapauth/trunk/check.py	2004-07-21 00:38:02 UTC (rev 26645)
@@ -0,0 +1,62 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""A plugable authentication module for LDAP.
+
+$Id$
+"""
+import ldap
+from zope.security.proxy import trustedRemoveSecurityProxy
+
+from zope.interface import implements
+from interfaces import ICheckLDAPAdapter
+
+
+
+class CheckLDAPAdapter:
+    """A LDAP connection test adapter."""
+
+    implements(ICheckLDAPAdapter)
+
+    def __init__(self, context):
+        self.context = context
+        self.report = []
+    
+    def testConnection(self):
+        self.report = []
+        source = trustedRemoveSecurityProxy(self.context)
+        self.report.append("... check existing connection")
+
+        try:
+            conn = getattr(source, '_v_conn', None)
+            if conn:
+                self.report.append('... connection "%s" found' % conn)
+            else:
+                self.report.append("... no existing connection found")
+                self.report.append("... try to connect")
+             
+            if not conn:
+                connectstring = 'ldap://%s:%s' % (source.host, source.port)
+                self.report.append("... ... connecting to:")
+                self.report.append("... ... %s" % connectstring)
+                connection = ldap.initialize(connectstring)
+                self.report.append("... <strong>Connection OK!</strong>")
+                return self.report
+            else:
+                self.report.append("... <strong>Connection OK!</strong>")
+                return self.report
+        except:
+            self.report.append("... <strong>Connection test faild!</strong>")
+            return self.report
+            
+ 

Modified: ldapauth/trunk/configure.zcml
===================================================================
--- ldapauth/trunk/configure.zcml	2004-07-21 00:26:29 UTC (rev 26644)
+++ ldapauth/trunk/configure.zcml	2004-07-21 00:38:02 UTC (rev 26645)
@@ -23,8 +23,8 @@
     </content>
 
     <adapter
-        factory="ldapauth.connectiontest.LDAPTestAdapter"
-        provides="ldapauth.interfaces.ILDAPTestAdapter"
+        factory="ldapauth.check.CheckLDAPAdapter"
+        provides="ldapauth.interfaces.ICheckLDAPAdapter"
         for="*"
         />
 

Deleted: ldapauth/trunk/connectiontest.py
===================================================================
--- ldapauth/trunk/connectiontest.py	2004-07-21 00:26:29 UTC (rev 26644)
+++ ldapauth/trunk/connectiontest.py	2004-07-21 00:38:02 UTC (rev 26645)
@@ -1,62 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""A plugable authentication module for LDAP.
-
-$Id$
-"""
-import ldap
-from zope.security.proxy import trustedRemoveSecurityProxy
-
-from zope.interface import implements
-from interfaces import ILDAPTestAdapter
-
-
-
-class LDAPTestAdapter:
-    """A LDAP connection test adapter."""
-
-    implements(ILDAPTestAdapter)
-
-    def __init__(self, context):
-        self.context = context
-        self.report = []
-    
-    def testConnection(self):
-        self.report = []
-        source = trustedRemoveSecurityProxy(self.context)
-        self.report.append("... check existing connection")
-
-        try:
-            conn = getattr(source, '_v_conn', None)
-            if conn:
-                self.report.append('... connection "%s" found' % conn)
-            else:
-                self.report.append("... no existing connection found")
-                self.report.append("... try to connect")
-             
-            if not conn:
-                connectstring = 'ldap://%s:%s' % (source.host, source.port)
-                self.report.append("... ... connecting to:")
-                self.report.append("... ... %s" % connectstring)
-                connection = ldap.initialize(connectstring)
-                self.report.append("... <strong>Connection OK!</strong>")
-                return self.report
-            else:
-                self.report.append("... <strong>Connection OK!</strong>")
-                return self.report
-        except:
-            self.report.append("... <strong>Connection test faild!</strong>")
-            return self.report
-            
- 

Modified: ldapauth/trunk/interfaces.py
===================================================================
--- ldapauth/trunk/interfaces.py	2004-07-21 00:26:29 UTC (rev 26644)
+++ ldapauth/trunk/interfaces.py	2004-07-21 00:38:02 UTC (rev 26645)
@@ -52,7 +52,7 @@
 
 
 
-class ILDAPTestAdapter(Interface):
+class ICheckLDAPAdapter(Interface):
     """A test adapter for to test the connection between Zope and LDAP."""
 
     def testConnection():



More information about the Zope3-Checkins mailing list