[Zope-CVS] SVN: ldapadapter/trunk/ Added serverURL getter and
setter methods with regex support for split the name of host
and port
Roger Ineichen
roger at projekt01.ch
Sat Oct 9 13:00:26 EDT 2004
Log message for revision 27863:
Added serverURL getter and setter methods with regex support for split the name of host and port
Changed:
U ldapadapter/trunk/interfaces.py
U ldapadapter/trunk/utility.py
-=-
Modified: ldapadapter/trunk/interfaces.py
===================================================================
--- ldapadapter/trunk/interfaces.py 2004-10-09 16:54:44 UTC (rev 27862)
+++ ldapadapter/trunk/interfaces.py 2004-10-09 17:00:26 UTC (rev 27863)
@@ -66,6 +66,14 @@
),
default=u"ldap://localhost",
)
+ bindDN = TextLine(
+ title=_("Bind DN"),
+ default=u'',
+ )
+ bindPassword = TextLine(
+ title=_("Bind password"),
+ default=u'',
+ )
class IManageableLDAPAdapter(ILDAPAdapter,
ILDAPAdapterManagement):
Modified: ldapadapter/trunk/utility.py
===================================================================
--- ldapadapter/trunk/utility.py 2004-10-09 16:54:44 UTC (rev 27862)
+++ ldapadapter/trunk/utility.py 2004-10-09 17:00:26 UTC (rev 27863)
@@ -77,7 +77,30 @@
return LDAPConnection(conn)
+ def _getServerURL(self):
+ """Returns the server url from the host and port info."""
+ return self.host +':'+ self.port
+ def _setServerURL(self, url):
+ """Returns the server url from the host and port info.
+ ldap[s]://host:port
+ """
+ url = url.strip()
+ urlReg = '^ldap://[a-zA-Z\-\.]+:[\d]{1,5}'
+ if re.match(urlReg, url):
+ urlList = url.split(':')
+ if len(urlList) >= 2:
+ self.useSSL = urlList[0].endswith('s')
+ self.host = urlList[1][:3]
+ if len(urlList) = 3:
+ self.port = urlList[2]
+ self.url = url
+ else:
+ print "to small url"
+
+
+
+
class LDAPConnection(object):
implements(ILDAPConnection)
@@ -143,4 +166,6 @@
implements(IManageableLDAPAdapter)
- serverURL = u"ldap://localhost"
+ serverURL = property(self._getServerURL(), self._setServerURL(url))
+ bindDN = u''
+ bindPassword = u''
More information about the Zope-CVS
mailing list