File: test-ldapserver.tac

package info (click to toggle)
ldaptor 0.0.43%2Bdebian1-3
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 2,168 kB
  • ctags: 3,592
  • sloc: python: 18,670; xml: 787; makefile: 147; sh: 88
file content (35 lines) | stat: -rw-r--r-- 1,016 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# -*- python -*-
import shutil
from twisted.application import service, internet
from twisted.internet import protocol
from twisted.python import components
from twisted.trial import util
from ldaptor import ldiftree, interfaces
from ldaptor.protocols.ldap import ldapserver

DBPATH = 'ldaptor/test/ldif/webtests'
TMPDBPATH = '%s.tmp' % DBPATH
shutil.rmtree(TMPDBPATH, ignore_errors=True)
shutil.copytree(DBPATH, TMPDBPATH)
db = ldiftree.LDIFTreeEntry(TMPDBPATH)

class LDAPServerFactory(protocol.ServerFactory):
    protocol = ldapserver.LDAPServer

    def __init__(self, root):
        self.root = root

ldapserver.LDAPServer.debug = True

components.registerAdapter(lambda x: x.root,
                           LDAPServerFactory,
                           interfaces.IConnectedLDAPEntry)


application = service.Application("ldaptor-server")
myService = service.IServiceCollection(application)

factory = LDAPServerFactory(db)

myServer = internet.TCPServer(38942, factory)
myServer.setServiceParent(myService)