Ejemplo n.º 1
0
    def memcache_retrieve(self):
        '''If the data needs to be cached, cache it.'''
        if self._memcache_key is None or Context.env_unit_test():
            return None

        if self._memcache is None:
            self._memcache = Memcache()
        return self._memcache.retrieve(self._memcache_key)
Ejemplo n.º 2
0
    def memcache_purge(self):
        '''If the data has been cached, purge it.'''
        if self._memcache_key is None or Context.env_unit_test():
            return

        if self._memcache is None:
            self._memcache = Memcache()
        self._memcache.purge(self._memcache_key)
Ejemplo n.º 3
0
    def memcache_retrieve(self):
        '''If the data needs to be cached, cache it.'''
        if self._memcache_key is None or Context.env_unit_test():
            return None

        if self._memcache is None:
            self._memcache = Memcache()
        return self._memcache.retrieve(self._memcache_key)
Ejemplo n.º 4
0
    def memcache_purge(self):
        '''If the data has been cached, purge it.'''
        if self._memcache_key is None or Context.env_unit_test():
            return

        if self._memcache is None:
            self._memcache = Memcache()
        self._memcache.purge(self._memcache_key)
Ejemplo n.º 5
0
    def memcache_store(self, data):
        '''If there is data and it should be cached, cache it.'''
        if self._memcache_key is None or Context.env_unit_test():
            return

        if self._memcache is None:
            self._memcache = Memcache()

        self._memcache.store(self._memcache_key, data, self._memcache_ttl,
                             self._memcache_ttl)
Ejemplo n.º 6
0
 def commit(self, ignore_exceptions=False):
     if self.__postgresql is None:
         if not ignore_exceptions:
             raise DataStoreException(
                 'transaction cannot be committed because a database ' +
                 'connection has not been established yet')
     else:
         if Context.env_unit_test():
             return
         else:
             self.connect()
             self.__postgresql.commit()
Ejemplo n.º 7
0
 def commit(self, ignore_exceptions=False):
     if self.__mysql is None:
         if not ignore_exceptions:
             raise DataStoreException(
                 'transaction cannot be committed because a database '
                 + 'connection has not been established yet'
             )
     else:
         if Context.env_unit_test():
             return
         else:
             self.connect()
             self.__mysql.commit()
Ejemplo n.º 8
0
    def memcache_store(self, data):
        '''If there is data and it should be cached, cache it.'''
        if self._memcache_key is None or Context.env_unit_test():
            return

        if self._memcache is None:
            self._memcache = Memcache()

        self._memcache.store(
            self._memcache_key,
            data,
            self._memcache_ttl,
            self._memcache_ttl)