Mercurial > libervia-web
comparison libervia.tac @ 59:d0fa4e96a5e4
server side: 404 error is now sent instead of directory listing when requesting a directory
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 29 May 2011 18:39:01 +0200 |
parents | e552a67b933d |
children | 80c490e6a1a7 |
comparison
equal
deleted
inserted
replaced
58:4fa3d57f72f8 | 59:d0fa4e96a5e4 |
---|---|
34 from twisted.mail.smtp import sendmail | 34 from twisted.mail.smtp import sendmail |
35 from twisted.web import server | 35 from twisted.web import server |
36 from twisted.web import error as weberror | 36 from twisted.web import error as weberror |
37 from twisted.web.static import File | 37 from twisted.web.static import File |
38 from twisted.web.resource import Resource | 38 from twisted.web.resource import Resource |
39 from twisted.web.error import NoResource | |
39 from twisted.python.components import registerAdapter | 40 from twisted.python.components import registerAdapter |
40 from twisted.words.protocols.jabber.jid import JID | 41 from twisted.words.protocols.jabber.jid import JID |
41 from txjsonrpc.web import jsonrpc | 42 from txjsonrpc.web import jsonrpc |
42 from txjsonrpc import jsonrpclib | 43 from txjsonrpc import jsonrpclib |
43 from sat_frontends.bridge.DBus import DBusBridgeFrontend,BridgeExceptionNoService | 44 from sat_frontends.bridge.DBus import DBusBridgeFrontend,BridgeExceptionNoService |
82 self.touch() | 83 self.touch() |
83 | 84 |
84 def touch(self): | 85 def touch(self): |
85 if not self.__lock: | 86 if not self.__lock: |
86 server.Session.touch(self) | 87 server.Session.touch(self) |
88 | |
89 class ProtectedFile(File): | |
90 """A File class which doens't show directory listing""" | |
91 | |
92 def directoryListing(self): | |
93 return NoResource() | |
87 | 94 |
88 class SATActionIDHandler(object): | 95 class SATActionIDHandler(object): |
89 """Manage SàT action id lifecycle""" | 96 """Manage SàT action id lifecycle""" |
90 ID_LIFETIME = 30 #after this time (in seconds), id will be suppressed and action result will be ignored | 97 ID_LIFETIME = 30 #after this time (in seconds), id will be suppressed and action result will be ignored |
91 | 98 |
569 | 576 |
570 | 577 |
571 class Libervia(service.Service): | 578 class Libervia(service.Service): |
572 | 579 |
573 def __init__(self): | 580 def __init__(self): |
574 root = File(LIBERVIA_DIR) | 581 root = ProtectedFile(LIBERVIA_DIR) |
575 self.signal_handler = SignalHandler(self) | 582 self.signal_handler = SignalHandler(self) |
576 _register = Register(self) | 583 _register = Register(self) |
577 self.signal_handler.plugRegister(_register) | 584 self.signal_handler.plugRegister(_register) |
578 self.sessions = {} #key = session value = user | 585 self.sessions = {} #key = session value = user |
579 self.prof_connected = set() #Profiles connected | 586 self.prof_connected = set() #Profiles connected |
593 self.bridge.register(signal_name, self.signal_handler.getGenericCb(signal_name)) | 600 self.bridge.register(signal_name, self.signal_handler.getGenericCb(signal_name)) |
594 root.putChild('json_signal_api', self.signal_handler) | 601 root.putChild('json_signal_api', self.signal_handler) |
595 root.putChild('json_api', MethodHandler(self)) | 602 root.putChild('json_api', MethodHandler(self)) |
596 root.putChild('register_api', _register) | 603 root.putChild('register_api', _register) |
597 root.putChild('blog', MicroBlog(self)) | 604 root.putChild('blog', MicroBlog(self)) |
598 root.putChild('css', File("server_css/")) | 605 root.putChild('css', ProtectedFile("server_css/")) |
599 self.site = server.Site(root) | 606 self.site = server.Site(root) |
600 self.site.sessionFactory = LiberviaSession | 607 self.site.sessionFactory = LiberviaSession |
601 | 608 |
602 def startService(self): | 609 def startService(self): |
603 reactor.listenTCP(8080, self.site) | 610 reactor.listenTCP(8080, self.site) |