示例#1
0
文件: db.py 项目: mflorin/ir
        del data


    """
    Load product data from the db

    @return True on success
    @return False on error
    """
    def load(self):
        f = open(self.config['file_name'], 'rb')
        data = cPickle.load(f)
        f.close()
        Event.dispatch('db.load', data)
        del data
    
    
    """
    'save' command
    """
    def saveCmd(self, *args):
        if self.config['persistence']:
            self.save()
            return Command.result(Command.RET_SUCCESS)
        else:
            return Command.result(Command.RET_ERR_GENERAL, 'database persistence is disabled')


Module.register('db', Db()) 
示例#2
0
    def stop(self):
        if self.running:
            Logger.info('stopping the TTL manager')
            self.running = False
            self.event.set()
            # in case of a reload, the event flag has to be clear
            # so that the next wait would actually wait
            self.event.clear()
            self.join()

    def reloadEvent(self, *args):
        self.stop()
        # we need this to start the thread again
        super(Expiration, self).__init__()
        self.loadConfig()
        self.start()

    def shutdownEvent(self, *args):
        self.stop()



class ItemReservation:
    @staticmethod
    def init():
        Product.init()
        exp = Expiration()

# register the module
Module.register('Item Reservation', ItemReservation)