diff 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
line wrap: on
line diff
--- a/libervia.tac	Sat Jun 18 15:47:21 2011 +0200
+++ b/libervia.tac	Sun Jun 19 00:48:43 2011 +0200
@@ -52,7 +52,8 @@
 
 TIMEOUT = 10 #Session's time out, after that the user will be disconnected
 LIBERVIA_DIR = "output/"
-CARDS_DIR = "cards/"
+MEDIA_DIR = "media/"
+CARDS_DIR = "games/cards/tarot"
 
 class ISATSession(Interface):
     profile = Attribute("Sat profile")
@@ -242,7 +243,9 @@
 
     def jsonrpc_getTarotCardsPaths(self):
         """Give the path of all the tarot cards"""
-        return map(lambda x: x[len(LIBERVIA_DIR):],glob.glob(os.path.join(LIBERVIA_DIR,CARDS_DIR,'*_*.png')));
+        _join = os.path.join
+        _media_dir = _join(self.sat_host.media_dir,'')
+        return map(lambda x: _join(MEDIA_DIR, x[len(_media_dir):]),glob.glob(_join(_media_dir,CARDS_DIR,'*_*.png')));
 
     def jsonrpc_tarotGameReady(self, player, referee):
         """Tell to the server that we are ready to start the game"""
@@ -602,11 +605,13 @@
                             'tarotGameChooseContrat', 'tarotGameShowCards', 'tarotGameInvalidCards', 'tarotGameCardsPlayed', 'tarotGameYourTurn', 'tarotGameScore',
                             'subscribe', 'contactDeleted', 'newContact']:
             self.bridge.register(signal_name, self.signal_handler.getGenericCb(signal_name))
+        self.media_dir = self.bridge.getConfig('','media_dir')
         root.putChild('json_signal_api', self.signal_handler)
         root.putChild('json_api', MethodHandler(self))
         root.putChild('register_api', _register)
         root.putChild('blog', MicroBlog(self))
         root.putChild('css', ProtectedFile("server_css/"))
+        root.putChild(os.path.dirname(MEDIA_DIR), ProtectedFile(self.media_dir))
         self.site = server.Site(root)
         self.site.sessionFactory = LiberviaSession