~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to daemons/librarian.tac

  • Committer: Guilherme Salgado
  • Date: 2008-09-12 19:30:19 UTC
  • mto: This revision was merged to the branch mainline in revision 7018.
  • Revision ID: salgado@canonical.com-20080912193019-tjq891zb8i2o164a
A couple changes after Francis' review

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
# Service that announces when the daemon is ready
34
34
tachandler.ReadyService().setServiceParent(librarianService)
35
35
 
36
 
# Public librarian.
37
 
public_storage = storage.LibrarianStorage(path, db.Library(restricted=False))
 
36
def setUpListener(uploadPort, webPort, restricted):
 
37
    """Set up a librarian listener on the given ports.
 
38
 
 
39
    :param restricted: Should this be a restricted listener?  A restricted
 
40
        listener will serve only files with the 'restricted' file set and all
 
41
        files uploaded through the restricted listener will have that flag
 
42
        set.
 
43
    """
 
44
    librarian_storage = storage.LibrarianStorage(
 
45
        path, db.Library(restricted=restricted))
 
46
    upload_factory = FileUploadFactory(librarian_storage)
 
47
    strports.service(str(uploadPort), upload_factory).setServiceParent(
 
48
        librarianService)
 
49
    root = fatweb.LibraryFileResource(
 
50
        librarian_storage, upstreamHost, upstreamPort)
 
51
    root.putChild('search', fatweb.DigestSearchResource(librarian_storage))
 
52
    root.putChild('robots.txt', fatweb.robotsTxt)
 
53
    site = server.Site(root)
 
54
    site.displayTracebacks = False
 
55
    strports.service(str(webPort), site).setServiceParent(librarianService)
 
56
 
 
57
# Set up the public librarian.
38
58
uploadPort = config.librarian.upload_port
39
 
upload_factory = FileUploadFactory(public_storage)
40
 
strports.service(str(uploadPort), upload_factory).setServiceParent(
41
 
    librarianService)
42
 
root = fatweb.LibraryFileResource(public_storage, upstreamHost, upstreamPort)
43
 
root.putChild('search', fatweb.DigestSearchResource(public_storage))
44
 
root.putChild('robots.txt', fatweb.robotsTxt)
45
 
site = server.Site(root)
46
 
site.displayTracebacks = False
47
59
webPort = config.librarian.download_port
48
 
strports.service(str(webPort), site).setServiceParent(librarianService)
 
60
setUpLibrarian(uploadPort, webPort, restricted=False)
49
61
 
50
 
# Restricted librarian.
 
62
# Set up the restricted librarian.
 
63
webPort = config.librarian.restricted_download_port
51
64
uploadPort = config.librarian.restricted_upload_port
52
 
restricted_storage = storage.LibrarianStorage(
53
 
    path, db.Library(restricted=True))
54
 
restricted_upload_factory = FileUploadFactory(restricted_storage)
55
 
strports.service(str(uploadPort), restricted_upload_factory).setServiceParent(
56
 
    librarianService)
57
 
root = fatweb.LibraryFileResource(
58
 
    restricted_storage, upstreamHost, upstreamPort)
59
 
root.putChild('search', fatweb.DigestSearchResource(restricted_storage))
60
 
root.putChild('robots.txt', fatweb.robotsTxt)
61
 
site = server.Site(root)
62
 
site.displayTracebacks = False
63
 
webPort = config.librarian.restricted_download_port
64
 
strports.service(str(webPort), site).setServiceParent(librarianService)
 
65
setUpLibrarian(uploadPort, webPort, restricted=True)