33
33
# Service that announces when the daemon is ready
34
34
tachandler.ReadyService().setServiceParent(librarianService)
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.
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
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(
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)
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(
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)
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(
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)