Mercurial > libervia-web
comparison libervia.tac @ 77:975e6be24e11
media paths update
media now use global media location, obtained throught getConfig('', 'media_dir')
Tarot cards have been removed as they are now shared in this location
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 19 Jun 2011 00:48:43 +0200 |
parents | b096facaa5b3 |
children | c3fb3292f582 |
comparison
equal
deleted
inserted
replaced
76:8f097c1551f3 | 77:975e6be24e11 |
---|---|
50 from server_side.blog import MicroBlog | 50 from server_side.blog import MicroBlog |
51 from zope.interface import Interface, Attribute, implements | 51 from zope.interface import Interface, Attribute, implements |
52 | 52 |
53 TIMEOUT = 10 #Session's time out, after that the user will be disconnected | 53 TIMEOUT = 10 #Session's time out, after that the user will be disconnected |
54 LIBERVIA_DIR = "output/" | 54 LIBERVIA_DIR = "output/" |
55 CARDS_DIR = "cards/" | 55 MEDIA_DIR = "media/" |
56 CARDS_DIR = "games/cards/tarot" | |
56 | 57 |
57 class ISATSession(Interface): | 58 class ISATSession(Interface): |
58 profile = Attribute("Sat profile") | 59 profile = Attribute("Sat profile") |
59 jid = Attribute("JID associated with the profile") | 60 jid = Attribute("JID associated with the profile") |
60 | 61 |
240 profile = ISATSession(self.session).profile | 241 profile = ISATSession(self.session).profile |
241 self.sat_host.bridge.tarotGameLaunch(other_players, profile) | 242 self.sat_host.bridge.tarotGameLaunch(other_players, profile) |
242 | 243 |
243 def jsonrpc_getTarotCardsPaths(self): | 244 def jsonrpc_getTarotCardsPaths(self): |
244 """Give the path of all the tarot cards""" | 245 """Give the path of all the tarot cards""" |
245 return map(lambda x: x[len(LIBERVIA_DIR):],glob.glob(os.path.join(LIBERVIA_DIR,CARDS_DIR,'*_*.png'))); | 246 _join = os.path.join |
247 _media_dir = _join(self.sat_host.media_dir,'') | |
248 return map(lambda x: _join(MEDIA_DIR, x[len(_media_dir):]),glob.glob(_join(_media_dir,CARDS_DIR,'*_*.png'))); | |
246 | 249 |
247 def jsonrpc_tarotGameReady(self, player, referee): | 250 def jsonrpc_tarotGameReady(self, player, referee): |
248 """Tell to the server that we are ready to start the game""" | 251 """Tell to the server that we are ready to start the game""" |
249 profile = ISATSession(self.session).profile | 252 profile = ISATSession(self.session).profile |
250 self.sat_host.bridge.tarotGameReady(player, referee) | 253 self.sat_host.bridge.tarotGameReady(player, referee) |
600 self.bridge.register("actionResult", self.action_handler.actionResultCb, "request") | 603 self.bridge.register("actionResult", self.action_handler.actionResultCb, "request") |
601 for signal_name in ['presenceUpdate', 'personalEvent', 'newMessage', 'roomJoined', 'roomUserJoined', 'roomUserLeft', 'tarotGameStarted', 'tarotGameNew', | 604 for signal_name in ['presenceUpdate', 'personalEvent', 'newMessage', 'roomJoined', 'roomUserJoined', 'roomUserLeft', 'tarotGameStarted', 'tarotGameNew', |
602 'tarotGameChooseContrat', 'tarotGameShowCards', 'tarotGameInvalidCards', 'tarotGameCardsPlayed', 'tarotGameYourTurn', 'tarotGameScore', | 605 'tarotGameChooseContrat', 'tarotGameShowCards', 'tarotGameInvalidCards', 'tarotGameCardsPlayed', 'tarotGameYourTurn', 'tarotGameScore', |
603 'subscribe', 'contactDeleted', 'newContact']: | 606 'subscribe', 'contactDeleted', 'newContact']: |
604 self.bridge.register(signal_name, self.signal_handler.getGenericCb(signal_name)) | 607 self.bridge.register(signal_name, self.signal_handler.getGenericCb(signal_name)) |
608 self.media_dir = self.bridge.getConfig('','media_dir') | |
605 root.putChild('json_signal_api', self.signal_handler) | 609 root.putChild('json_signal_api', self.signal_handler) |
606 root.putChild('json_api', MethodHandler(self)) | 610 root.putChild('json_api', MethodHandler(self)) |
607 root.putChild('register_api', _register) | 611 root.putChild('register_api', _register) |
608 root.putChild('blog', MicroBlog(self)) | 612 root.putChild('blog', MicroBlog(self)) |
609 root.putChild('css', ProtectedFile("server_css/")) | 613 root.putChild('css', ProtectedFile("server_css/")) |
614 root.putChild(os.path.dirname(MEDIA_DIR), ProtectedFile(self.media_dir)) | |
610 self.site = server.Site(root) | 615 self.site = server.Site(root) |
611 self.site.sessionFactory = LiberviaSession | 616 self.site.sessionFactory = LiberviaSession |
612 | 617 |
613 def startService(self): | 618 def startService(self): |
614 reactor.listenTCP(8080, self.site) | 619 reactor.listenTCP(8080, self.site) |