def test_cache_page_new_style(self): """ Test that we can call cache_page the new way """ def my_view(request): return "response" my_view_cached = cache_page(123)(my_view) self.assertEqual(my_view_cached(HttpRequest()), "response") my_view_cached2 = cache_page(123, key_prefix="test")(my_view) self.assertEqual(my_view_cached2(HttpRequest()), "response")
def test_cache_page_is_mobile(self): """ Test that we can call cache_page in mobile page """ def is_mobile_view(request): return request.is_mobile def mobile_view(request): return 'response' mobile_view_cached = cache_page(123)(mobile_view) is_mobile_view_cached = cache_page(123)(is_mobile_view) request = HttpRequest() request.is_mobile = True self.assertEqual(mobile_view_cached(request), "response") self.assertTrue(is_mobile_view_cached(request))
#!/usr/bin/env python # -*- coding: utf-8 -*- from django.conf.urls import patterns, url from django.contrib.sitemaps import views as sitemap_views from opps.core.cache import cache_page from opps.sitemaps.sitemaps import GenericSitemap, InfoDisct sitemaps = { 'containers': GenericSitemap(InfoDisct(), priority=0.6), } sitemaps_googlenews = { 'containers': GenericSitemap(InfoDisct(True), priority=0.6), } urlpatterns = patterns( '', url(r'^\.xml$', cache_page(86400)(sitemap_views.index), {'sitemaps': sitemaps}), url(r'^-googlenews\.xml$', cache_page(86400)(sitemap_views.sitemap), {'sitemaps': sitemaps_googlenews, 'template_name': 'sitemap_googlenews.xml'}), url(r'^-(?P<section>.+)\.xml$', cache_page(86400)(sitemap_views.sitemap), {'sitemaps': sitemaps}), )
#!/usr/bin/env python # -*- coding: utf-8 -*- from django.conf.urls import patterns, url from django.contrib.sitemaps import views as sitemap_views from opps.core.cache import cache_page from opps.sitemaps.sitemaps import GenericSitemap, InfoDict from opps.sitemaps.views import sitemap sitemaps = { 'containers': GenericSitemap(InfoDict(), priority=0.6), } sitemaps_googlenews = { 'containers': GenericSitemap(InfoDict(True), priority=0.6), } urlpatterns = patterns( '', url(r'^\.xml$', cache_page(86400)(sitemap_views.index), {'sitemaps': sitemaps, 'sitemap_url_name': 'sitemaps'},), url(r'^-googlenews\.xml$', cache_page(86400)(sitemap), {'sitemaps': sitemaps_googlenews, 'template_name': 'sitemap_googlenews.xml'}), url(r'^-(?P<section>.+)\.xml$', cache_page(86400)(sitemap_views.sitemap), {'sitemaps': sitemaps}, name='sitemaps'), )
#!/usr/bin/env python # -*- coding: utf-8 -*- from django.conf.urls import patterns, url from django.conf import settings from opps.core.cache import cache_page from .views import AsyncServer, LongPullingServer urlpatterns = patterns( '', url(r'^(?P<channel__long_slug>[\w//-]+)/(?P<slug>[\w-]+)\.server$', cache_page(settings.OPPS_CACHE_EXPIRE_DETAIL)(AsyncServer.as_view()), name='asyncserver'), url(r'^(?P<channel__long_slug>[\w//-]+)/(?P<slug>[\w-]+)\.pulingserver$', cache_page(settings.OPPS_CACHE_EXPIRE_DETAIL)( LongPullingServer.as_view()), name='pulingserver'), )
from django.conf import settings from opps.contrib.feeds.views import (ContainerFeed, ChannelFeed, ContainerAtomFeed, ChannelAtomFeed) from opps.core.tags.views import TagList from opps.core.cache import cache_page from .views import ContainerList, ContainerDetail from .views import Search urlpatterns = patterns( '', url(r'^$', ContainerList.as_view(), name='home'), url(r'^(rss|feed)$', cache_page(settings.OPPS_CACHE_EXPIRE)( ContainerFeed()), name='feed'), url(r'^atom$', cache_page(settings.OPPS_CACHE_EXPIRE)( ContainerAtomFeed()), name='atom_feed'), url(r'^search/', Search(), name='search'), url(r'^tag/(?P<tag>[\w//-]+)$', cache_page(settings.OPPS_CACHE_EXPIRE)( TagList.as_view()), name='tag_open'), url(r'^(?P<long_slug>[\w\b//-]+)/(rss|feed)$', cache_page(settings.OPPS_CACHE_EXPIRE)( ChannelFeed()), name='channel_feed'), url(r'^(?P<long_slug>[\w\b//-]+)/atom$',
#!/usr/bin/env python # -*- coding: utf-8 -*- from django.conf.urls import patterns, url from django.contrib.sitemaps import views as sitemap_views from opps.core.cache import cache_page from opps.sitemaps.sitemaps import GenericSitemap, InfoDict sitemaps = {"containers": GenericSitemap(InfoDict(), priority=0.6)} sitemaps_googlenews = {"containers": GenericSitemap(InfoDict(True), priority=0.6)} urlpatterns = patterns( "", url(r"^\.xml$", cache_page(86400)(sitemap_views.index), {"sitemaps": sitemaps, "sitemap_url_name": "sitemaps"}), url( r"^-googlenews\.xml$", cache_page(86400)(sitemap_views.sitemap), {"sitemaps": sitemaps_googlenews, "template_name": "sitemap_googlenews.xml"}, ), url(r"^-(?P<section>.+)\.xml$", cache_page(86400)(sitemap_views.sitemap), {"sitemaps": sitemaps}, name="sitemaps"), )
from django.conf.urls import patterns, url from django.conf import settings from opps.contrib.feeds.views import (ContainerFeed, ChannelFeed, ContainerAtomFeed, ChannelAtomFeed) from opps.core.tags.views import TagList from opps.core.cache import cache_page from .views import ContainerList, ContainerDetail from .views import Search urlpatterns = patterns( '', url(r'^$', ContainerList.as_view(), name='home'), url(r'^(rss|feed)$', cache_page(settings.OPPS_CACHE_EXPIRE)(ContainerFeed()), name='feed'), url(r'^atom$', cache_page(settings.OPPS_CACHE_EXPIRE)(ContainerAtomFeed()), name='atom_feed'), url(r'^search/', Search(), name='search'), url(r'^tag/(?P<tag>[\w//-]+)$', cache_page(settings.OPPS_CACHE_EXPIRE)(TagList.as_view()), name='tag_open'), url(r'^(?P<long_slug>[\w\b//-]+)/(rss|feed)$', cache_page(settings.OPPS_CACHE_EXPIRE)(ChannelFeed()), name='channel_feed'), url(r'^(?P<long_slug>[\w\b//-]+)/atom$', cache_page(settings.OPPS_CACHE_EXPIRE)(ChannelAtomFeed()), name='channel_atom_feed'), url(r'^(?P<channel__long_slug>[\w//-]+)/(?P<slug>[\w-]+)\.html$',
#!/usr/bin/env python # -*- coding: utf-8 -*- from django.conf.urls import patterns, url from django.conf import settings from opps.core.cache import cache_page from .views import AlbumList from .views import AlbumChannelList urlpatterns = patterns( '', url(r'^albums/$', cache_page(settings.OPPS_CACHE_EXPIRE_LIST)(AlbumList.as_view()), name='album_list'), url(r'^album/(?P<channel__long_slug>[\w\b//-]+)/$', cache_page(settings.OPPS_CACHE_EXPIRE_LIST)( AlbumChannelList.as_view()), name='album_channel'), )
#!/usr/bin/env python # -*- coding: utf-8 -*- from django.conf.urls import patterns, url from django.conf import settings from opps.core.cache import cache_page from .views import AsyncServer, LongPullingServer urlpatterns = patterns( '', url(r'^(?P<channel__long_slug>[\w//-]+)/(?P<slug>[\w-]+)\.server$', cache_page(settings.OPPS_CACHE_EXPIRE_DETAIL)( AsyncServer.as_view()), name='asyncserver'), url(r'^(?P<channel__long_slug>[\w//-]+)/(?P<slug>[\w-]+)\.pulingserver$', cache_page(settings.OPPS_CACHE_EXPIRE_DETAIL)( LongPullingServer.as_view()), name='pulingserver'), )
from opps.sitemaps.sitemaps import GenericSitemap, InfoDict from opps.sitemaps.views import sitemap sitemaps = { 'containers': GenericSitemap(InfoDict(), priority=0.6), } sitemaps_googlenews = { 'containers': GenericSitemap(InfoDict(True), priority=0.6), } urlpatterns = patterns( '', url( r'^\.xml$', cache_page(86400)(sitemap_views.index), { 'sitemaps': sitemaps, 'sitemap_url_name': 'sitemaps' }, ), url(r'^-googlenews\.xml$', cache_page(86400)(sitemap), { 'sitemaps': sitemaps_googlenews, 'template_name': 'sitemap_googlenews.xml' }), url(r'^-(?P<section>.+)\.xml$', cache_page(86400)(sitemap_views.sitemap), {'sitemaps': sitemaps}, name='sitemaps'), )
#!/usr/bin/env python # -*- coding: utf-8 -*- from django.conf.urls import patterns, url from django.conf import settings from opps.core.cache import cache_page from .views import AlbumList from .views import AlbumChannelList urlpatterns = patterns( '', url(r'^albums/$', cache_page(settings.OPPS_CACHE_EXPIRE_LIST)( AlbumList.as_view()), name='album_list'), url(r'^album/(?P<channel__long_slug>[\w\b//-]+)/$', cache_page(settings.OPPS_CACHE_EXPIRE_LIST)( AlbumChannelList.as_view()), name='album_channel'), )
from django.conf import settings from opps.contrib.feeds.views import ContainerFeed, ChannelFeed from opps.core.tags.views import TagList from opps.core.cache import cache_page from .views import ContainerList, ContainerDetail from .views import ContainerAPIList, ContainerAPIDetail from .views import Search urlpatterns = patterns( '', url(r'^$', ContainerList.as_view(), name='home'), url(r'^(rss|feed)$', cache_page(settings.OPPS_CACHE_EXPIRE)( ContainerFeed()), name='feed'), url(r'^search/', Search(), name='search'), url(r'^tag/(?P<tag>[\w//-]+)$', cache_page(settings.OPPS_CACHE_EXPIRE)( TagList.as_view()), name='tag_open'), url(r'^(?P<long_slug>[\w\b//-]+)/(rss|feed)$', cache_page(settings.OPPS_CACHE_EXPIRE)( ChannelFeed()), name='channel_feed'), url(r'^(?P<channel__long_slug>[\w//-]+)/(?P<slug>[\w-]+).api$', cache_page(settings.OPPS_CACHE_EXPIRE_DETAIL)( ContainerAPIDetail.as_view()), name='open-api'), url(r'^(?P<channel__long_slug>[\w//-]+)/(?P<slug>[\w-]+)\.html$',
from django.conf import settings from django.conf.urls import patterns, url from django.contrib.sitemaps import views as sitemap_views from opps.core.cache import cache_page from opps.sitemaps.sitemaps import GenericSitemap, InfoDict from opps.sitemaps.views import sitemap sitemaps = { 'containers': GenericSitemap(InfoDict(), priority=0.6), } sitemaps_googlenews = { 'containers': GenericSitemap(InfoDict(True), priority=0.6), } urlpatterns = patterns( '', url(r'^\.xml$', cache_page(settings.OPPS_CACHE_EXPIRE)( sitemap_views.index), {'sitemaps': sitemaps, 'sitemap_url_name': 'sitemaps'},), url(r'^-googlenews\.xml$', cache_page(settings.OPPS_CACHE_EXPIRE)(sitemap), {'sitemaps': sitemaps_googlenews, 'template_name': 'sitemap_googlenews.xml'}), url(r'^-(?P<section>.+)\.xml$', cache_page(settings.OPPS_CACHE_EXPIRE)(sitemap_views.sitemap), {'sitemaps': sitemaps}, name='sitemaps'), )
#!/usr/bin/env python # -*- coding: utf-8 -*- from django.conf.urls import patterns, url from .conf import settings from opps.core.cache import cache_page #from .views import ContainerList, ContainerDetail from .views import ContainerList urlpatterns = patterns( '', #url(r'^$', ContainerList.as_view(), name='home'), url(r'^(?P<channel_long_slug>[\w\b//-]+)/$', cache_page(settings.OPPS_CACHE_EXPIRE_LIST)(ContainerList.as_view()), name='channel'), )
#!/usr/bin/env python # -*- coding: utf-8 -*- from django.conf.urls import patterns, url from opps.core.cache import cache_page from .views import PageDetail urlpatterns = patterns( '', # FLATPAGEs url(r'^page/(?P<slug>[\w\b//-]+)/$', cache_page(60 * 2)(PageDetail.as_view()), name='open'), )
#!/usr/bin/env python # -*- coding: utf-8 -*- from django.conf.urls import patterns, url from .conf import settings from opps.core.cache import cache_page #from .views import ContainerList, ContainerDetail from .views import ContainerList urlpatterns = patterns( '', #url(r'^$', ContainerList.as_view(), name='home'), url(r'^(?P<channel_long_slug>[\w\b//-]+)/$', cache_page(settings.OPPS_CACHE_EXPIRE_LIST)( ContainerList.as_view()), name='channel'), )