Update of /cvsroot/freevo/freevo/src/mediadb
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21854/src/mediadb

Modified Files:
        db.py item.py 
Log Message:
replace call_later with OneShotTimer

Index: db.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/mediadb/db.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** db.py       25 Jun 2005 08:52:26 -0000      1.11
--- db.py       17 Jul 2005 09:05:26 -0000      1.12
***************
*** 42,50 ****
  from stat import *
  
  # freevo imports
  import sysconfig
  import util.vfs as vfs
  import util.cache as cache
- from util.callback import *
  
  # mediadb imports
--- 42,52 ----
  from stat import *
  
+ # kaa imports
+ from kaa.notifier import OneShotTimer
+ 
  # freevo imports
  import sysconfig
  import util.vfs as vfs
  import util.cache as cache
  
  # mediadb imports
***************
*** 90,94 ****
          """
          for cache in self.caches.values():
!             cache.save()
  
  
--- 92,96 ----
          """
          for cache in self.caches.values():
!             cache.save(False)
  
  
***************
*** 102,105 ****
--- 104,110 ----
      """
      def __init__(self, dirname):
+         # save timer
+         self.__save_timer = OneShotTimer(self.save, False)
+         self.__save_timer.restart_when_active = False
          # create full path
          dirname = os.path.normpath(os.path.abspath(dirname))
***************
*** 142,146 ****
              # process.
              self.changed = True
!             self.save()
          # 'normal' files
          self.files   = self.data[ITEMS]
--- 147,151 ----
              # process.
              self.changed = True
!             self.save(False)
          # 'normal' files
          self.files   = self.data[ITEMS]
***************
*** 184,189 ****
              # no overlay dir
              self.check_time = time.time()
!             if self.changed:
!                 call_later(self.save)
              return
  
--- 189,193 ----
              # no overlay dir
              self.check_time = time.time()
!             self.save()
              return
  
***************
*** 288,298 ****
          if overlay:
              self.check_time = time.time()
!             if self.changed:
!                 call_later(self.save)
              return
          self.check(True)
  
  
!     def save(self):
          """
          Save the cache.
--- 292,301 ----
          if overlay:
              self.check_time = time.time()
!             self.save()
              return
          self.check(True)
  
  
!     def save(self, later=True):
          """
          Save the cache.
***************
*** 300,304 ****
          if not self.changed:
              return
!         log.debug('save %s' % self.cachefile)
          cache.save(self.cachefile, self.data, VERSION)
          self.mtime = os.stat(self.cachefile)[ST_MTIME]
--- 303,310 ----
          if not self.changed:
              return
!         if later:
!             self.__save_timer.start(0)
!             return
!         log.info('save %s' % self.cachefile)
          cache.save(self.cachefile, self.data, VERSION)
          self.mtime = os.stat(self.cachefile)[ST_MTIME]
***************
*** 399,403 ****
                  callback()
  
!         self.save()
          self.__check_global = False
          self.reduce_files = []
--- 405,409 ----
                  callback()
  
!         self.save(False)
          self.__check_global = False
          self.reduce_files = []
***************
*** 456,459 ****
--- 462,468 ----
      """
      def __init__(self, filename, db):
+         # save timer
+         self.__save_timer = OneShotTimer(self.save, False)
+         self.__save_timer.restart_when_active = False
          self.cachefile = db
          self.data = None
***************
*** 477,485 ****
              basename = filename[filename.rfind('/'):]
              parser.parse(basename, filename, self.data, self, [])
!             self.save()
          self.filename = filename
          
  
!     def save(self):
          """
          Save the cache.
--- 486,494 ----
              basename = filename[filename.rfind('/'):]
              parser.parse(basename, filename, self.data, self, [])
!             self.save(False)
          self.filename = filename
          
  
!     def save(self, later=True):
          """
          Save the cache.
***************
*** 487,490 ****
--- 496,502 ----
          if not self.changed:
              return
+         if later:
+             self.__save_timer.start(0)
+             return
          log.debug('save %s' % self.cachefile)
          cache.save(self.cachefile, self.data, VERSION)

Index: item.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/mediadb/item.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** item.py     2 Jul 2005 16:46:26 -0000       1.10
--- item.py     17 Jul 2005 09:05:27 -0000      1.11
***************
*** 37,43 ****
  import logging
  
- # freevo imports
- from util.callback import *
- 
  # mediadb globals
  from globals import *
--- 37,40 ----
***************
*** 128,132 ****
              if self.cache:
                  self.cache.changed = True
!                 call_later(self.cache.save)
          else:
              self.tmp[key] = value
--- 125,129 ----
              if self.cache:
                  self.cache.changed = True
!                 self.cache.save()
          else:
              self.tmp[key] = value
***************
*** 164,168 ****
          if self.cache:
              self.cache.changed = True
!             call_later(self.cache.save)
          return True
  
--- 161,165 ----
          if self.cache:
              self.cache.changed = True
!             self.cache.save()
          return True
  
***************
*** 177,181 ****
          if self.cache:
              self.cache.changed = True
!             call_later(self.cache.save)
          if not key in self.attr[MTIME_DEP]:
              self.attr[MTIME_DEP].append(key)
--- 174,178 ----
          if self.cache:
              self.cache.changed = True
!             self.cache.save()
          if not key in self.attr[MTIME_DEP]:
              self.attr[MTIME_DEP].append(key)



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to