Exemplo n.º 1
0
 def get_anonymous(self):
     user = cache.get('core/anonymous')
     if user is None:
         name = ctx.cfg['anonymous_name']
         user = User.query.get(name)
         cache.set('core/anonymous', user)
     user = db.session.merge(user, load=False)
     return user
Exemplo n.º 2
0
 def get_anonymous(self):
     user = cache.get('core/anonymous')
     if user is None:
         name = ctx.cfg['anonymous_name']
         user = User.query.get(name)
         cache.set('core/anonymous', user)
     user = db.session.merge(user, load=False)
     return user
Exemplo n.º 3
0
 def cached(self, key, timeout=None):
     """Return a query result from the cache or execute the query again"""
     from inyoka.core.cache import cache
     data = cache.get(key)
     if data is None:
         data = self.all()
         cache.set(key, data, timeout=timeout)
     data = list(self.merge_result(data, load=False))
     return data
Exemplo n.º 4
0
 def cached(self, key, timeout=None):
     """Return a query result from the cache or execute the query again"""
     from inyoka.core.cache import cache
     data = cache.get(key)
     if data is None:
         data = self.all()
         cache.set(key, data, timeout=timeout)
     data = list(self.merge_result(data, load=False))
     return data
Exemplo n.º 5
0
        def func(*args, **kwargs):
            if cache_key is not None:
                key = cache_key % kwargs
                content = cache.get(key)
                if content is not None:
                    mimetype = 'application/atom+xml; charset=utf-8'
                    return Response(content, mimetype=mimetype)

            feed = original(*args, **kwargs)
            if not isinstance(feed, AtomFeed):
                # ret is not a feed object so return it
                return feed

            response = feed.get_response()

            if cache_key is not None:
                cache.set(key, response.data, cache_timeout)
            return response
Exemplo n.º 6
0
        def func(*args, **kwargs):
            if cache_key is not None:
                key = cache_key % kwargs
                content = cache.get(key)
                if content is not None:
                    mimetype = 'application/atom+xml; charset=utf-8'
                    return Response(content, mimetype=mimetype)

            feed = original(*args, **kwargs)
            if not isinstance(feed, AtomFeed):
                # ret is not a feed object so return it
                return feed

            response = feed.get_response()

            if cache_key is not None:
                cache.set(key, response.data, cache_timeout)
            return response