~divmod-dev/divmod.org/compressed-resources-2747

« back to all changes in this revision

Viewing changes to Imaginary/imagination/deployment.py

  • Committer: exarkun
  • Date: 2006-02-26 02:37:39 UTC
  • Revision ID: svn-v4:866e43f7-fbfc-0310-8f2a-ec88d1da2979:trunk:4991
Merge move-pottery-to-trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
 
 
3
def deploy(telnetPort=23, sshPort=22, webPort=80,
 
4
 
 
5
           manholePort=9987, manholeUser='admin', manholePassword='password',
 
6
 
 
7
           actorTemplate=None,
 
8
 
 
9
           **kwargs):
 
10
 
 
11
    # Set up an Application and some cred goo
 
12
    from twisted.application import service
 
13
    from twisted.cred import portal, checkers
 
14
 
 
15
    application = service.Application("Imagination")
 
16
    svc = service.IServiceCollection(application)
 
17
 
 
18
    # Telnet server
 
19
    from twisted.application import internet
 
20
 
 
21
    from imagination.wiring.telnet import TextFactory
 
22
 
 
23
    telnetServer = internet.TCPServer(telnetPort, TextFactory(actorTemplate))
 
24
    telnetServer.setServiceParent(svc)
 
25
 
 
26
    # SSH server
 
27
    from imagination.wiring.ssh import ConchFactory
 
28
 
 
29
    conchServer = internet.TCPServer(sshPort, ConchFactory(actorTemplate))
 
30
    conchServer.setServiceParent(svc)
 
31
 
 
32
    # Web server
 
33
    from nevow import appserver, guard, liveevil, inevow
 
34
    from imagination.wiring import web
 
35
 
 
36
    class AnonRealm:
 
37
        def requestAvatar(self, avatarId, mind, *interfaces):
 
38
            return inevow.IResource, web.WebPage(actorTemplate), lambda:None
 
39
 
 
40
    webServer = internet.TCPServer(
 
41
        webPort,
 
42
        appserver.NevowSite(
 
43
            guard.SessionWrapper(
 
44
                portal.Portal(AnonRealm(), (checkers.AllowAnonymousAccess(), )),
 
45
                mindFactory=liveevil.LiveEvil))).setServiceParent(svc)
 
46
 
 
47
    # Manhole server
 
48
 
 
49
    from twisted.manhole import service as mhservice
 
50
    from twisted.spread import pb
 
51
 
 
52
    mhsvc = mhservice.Service(True)
 
53
    #mhsvc.namespace['store'] = st
 
54
 
 
55
    mhrealm = mhservice.Realm(mhsvc)
 
56
    mhpt = portal.Portal(mhrealm, [
 
57
        checkers.InMemoryUsernamePasswordDatabaseDontUse(**{manholeUser: manholePassword})
 
58
        ])
 
59
    serverFactory = pb.PBServerFactory(mhpt, True)
 
60
    manholeServer = internet.TCPServer(manholePort, serverFactory, interface="localhost")
 
61
    manholeServer.setServiceParent(svc)
 
62
 
 
63
    return application