=== renamed directory 'django/core/cache' => 'django/cache'
=== renamed file 'django/middleware/cache.py' => 'django/cache/middleware.py'
old
|
new
|
|
1 | 1 | from django.conf import settings |
2 | | from django.core.cache import cache |
3 | | from django.utils.cache import get_cache_key, learn_cache_key, patch_response_headers |
| 2 | from django.cache import cache |
| 3 | from django.cache.utils import get_cache_key, learn_cache_key, patch_response_headers |
4 | 4 | |
5 | 5 | class CacheMiddleware(object): |
6 | 6 | """ |
=== renamed file 'django/utils/cache.py' => 'django/cache/utils.py'
old
|
new
|
|
13 | 13 | different header content for headers named in "Vary" need to get different |
14 | 14 | cache keys to prevent delivery of wrong content. |
15 | 15 | |
16 | | A example: i18n middleware would need to distinguish caches by the |
| 16 | An example: i18n middleware would need to distinguish caches by the |
17 | 17 | "Accept-language" header. |
18 | 18 | """ |
19 | 19 | |
20 | 20 | import datetime, md5, re |
21 | 21 | from django.conf import settings |
22 | | from django.core.cache import cache |
| 22 | from django.cache import cache |
23 | 23 | |
24 | 24 | cc_delim_re = re.compile(r'\s*,\s*') |
25 | 25 | |
… |
… |
|
116 | 116 | value = request.META.get(header, None) |
117 | 117 | if value is not None: |
118 | 118 | ctx.update(value) |
119 | | return 'views.decorators.cache.cache_page.%s.%s.%s' % (key_prefix, request.path, ctx.hexdigest()) |
| 119 | return 'cache.decorators.cache_page.%s.%s.%s' % (key_prefix, request.path, ctx.hexdigest()) |
120 | 120 | |
121 | 121 | def get_cache_key(request, key_prefix=None): |
122 | 122 | """ |
… |
… |
|
130 | 130 | """ |
131 | 131 | if key_prefix is None: |
132 | 132 | key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX |
133 | | cache_key = 'views.decorators.cache.cache_header.%s.%s' % (key_prefix, request.path) |
| 133 | cache_key = 'cache.decorators.cache_header.%s.%s' % (key_prefix, request.path) |
134 | 134 | headerlist = cache.get(cache_key, None) |
135 | 135 | if headerlist is not None: |
136 | 136 | return _generate_cache_key(request, headerlist, key_prefix) |
… |
… |
|
154 | 154 | key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX |
155 | 155 | if cache_timeout is None: |
156 | 156 | cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS |
157 | | cache_key = 'views.decorators.cache.cache_header.%s.%s' % (key_prefix, request.path) |
| 157 | cache_key = 'cache.decorators.cache_header.%s.%s' % (key_prefix, request.path) |
158 | 158 | if response.has_header('Vary'): |
159 | 159 | headerlist = ['HTTP_'+header.upper().replace('-', '_') for header in vary_delim_re.split(response['Vary'])] |
160 | 160 | cache.set(cache_key, headerlist, cache_timeout) |
=== renamed file 'django/views/decorators/cache.py' => 'django/cache/decorators.py'
old
|
new
|
|
12 | 12 | """ |
13 | 13 | |
14 | 14 | from django.utils.decorators import decorator_from_middleware |
15 | | from django.utils.cache import patch_cache_control, add_never_cache_headers |
16 | | from django.middleware.cache import CacheMiddleware |
| 15 | from django.cache.utils import patch_cache_control, add_never_cache_headers |
| 16 | from django.cache.middleware import CacheMiddleware |
17 | 17 | |
18 | 18 | cache_page = decorator_from_middleware(CacheMiddleware) |
19 | 19 | |
=== modified file 'django/cache/__init__.py'
old
|
new
|
|
4 | 4 | This package defines set of cache backends that all conform to a simple API. |
5 | 5 | In a nutshell, a cache is a set of values -- which can be any object that |
6 | 6 | may be pickled -- identified by string keys. For the complete API, see |
7 | | the abstract BaseCache class in django.core.cache.backends.base. |
| 7 | the abstract BaseCache class in django.cache.backends.base. |
8 | 8 | |
9 | 9 | Client code should not access a cache backend directly; instead it should |
10 | 10 | either use the "cache" variable made available here, or it should use the |
… |
… |
|
17 | 17 | |
18 | 18 | from cgi import parse_qsl |
19 | 19 | from django.conf import settings |
20 | | from django.core.cache.backends.base import InvalidCacheBackendError |
| 20 | from django.cache.backends.base import InvalidCacheBackendError |
21 | 21 | |
22 | 22 | BACKENDS = { |
23 | 23 | # name for use in settings file --> name of module in "backends" directory |
… |
… |
|
48 | 48 | if host.endswith('/'): |
49 | 49 | host = host[:-1] |
50 | 50 | |
51 | | cache_class = getattr(__import__('django.core.cache.backends.%s' % BACKENDS[scheme], {}, {}, ['']), 'CacheClass') |
| 51 | cache_class = getattr(__import__('django.cache.backends.%s' % BACKENDS[scheme], {}, {}, ['']), 'CacheClass') |
52 | 52 | return cache_class(host, params) |
53 | 53 | |
54 | 54 | cache = get_cache(settings.CACHE_BACKEND) |
=== modified file 'django/cache/backends/db.py'
old
|
new
|
|
1 | 1 | "Database cache backend." |
2 | 2 | |
3 | | from django.core.cache.backends.base import BaseCache |
| 3 | from django.cache.backends.base import BaseCache |
4 | 4 | from django.db import connection, transaction, DatabaseError |
5 | 5 | import base64, time |
6 | 6 | from datetime import datetime |
=== modified file 'django/cache/backends/dummy.py'
old
|
new
|
|
1 | 1 | "Dummy cache backend" |
2 | 2 | |
3 | | from django.core.cache.backends.base import BaseCache |
| 3 | from django.cache.backends.base import BaseCache |
4 | 4 | |
5 | 5 | class CacheClass(BaseCache): |
6 | 6 | def __init__(self, *args, **kwargs): |
=== modified file 'django/cache/backends/filebased.py'
old
|
new
|
|
1 | 1 | "File-based cache backend" |
2 | 2 | |
3 | | from django.core.cache.backends.simple import CacheClass as SimpleCacheClass |
| 3 | from django.cache.backends.simple import CacheClass as SimpleCacheClass |
4 | 4 | import os, time, urllib |
5 | 5 | try: |
6 | 6 | import cPickle as pickle |
=== modified file 'django/cache/backends/locmem.py'
old
|
new
|
|
1 | 1 | "Thread-safe in-memory cache backend." |
2 | 2 | |
3 | | from django.core.cache.backends.simple import CacheClass as SimpleCacheClass |
| 3 | from django.cache.backends.simple import CacheClass as SimpleCacheClass |
4 | 4 | from django.utils.synch import RWLock |
5 | 5 | import copy, time |
6 | 6 | |
=== modified file 'django/cache/backends/memcached.py'
old
|
new
|
|
1 | 1 | "Memcached cache backend" |
2 | 2 | |
3 | | from django.core.cache.backends.base import BaseCache, InvalidCacheBackendError |
| 3 | from django.cache.backends.base import BaseCache, InvalidCacheBackendError |
4 | 4 | |
5 | 5 | try: |
6 | 6 | import cmemcache as memcache |
=== modified file 'django/cache/backends/simple.py'
old
|
new
|
|
1 | 1 | "Single-process in-memory cache backend." |
2 | 2 | |
3 | | from django.core.cache.backends.base import BaseCache |
| 3 | from django.cache.backends.base import BaseCache |
4 | 4 | import time |
5 | 5 | |
6 | 6 | class CacheClass(BaseCache): |
=== modified file 'django/conf/global_settings.py'
|
|
|
273 | 273 | # CACHE # |
274 | 274 | ######### |
275 | 275 | |
276 | | # The cache backend to use. See the docstring in django.core.cache for the |
| 276 | # The cache backend to use. See the docstring in django.cache for the |
277 | 277 | # possible values. |
278 | 278 | CACHE_BACKEND = 'simple://' |
279 | 279 | CACHE_MIDDLEWARE_KEY_PREFIX = '' |
=== modified file 'django/contrib/admin/views/main.py'
|
|
|
2 | 2 | from django.conf import settings |
3 | 3 | from django.contrib.admin.filterspecs import FilterSpec |
4 | 4 | from django.contrib.admin.views.decorators import staff_member_required |
5 | | from django.views.decorators.cache import never_cache |
| 5 | from django.cache.decorators import never_cache |
6 | 6 | from django.contrib.contenttypes.models import ContentType |
7 | 7 | from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist, PermissionDenied |
8 | 8 | from django.core.paginator import ObjectPaginator, InvalidPage |
=== modified file 'django/contrib/sessions/middleware.py'
|
|
|
1 | 1 | from django.conf import settings |
2 | 2 | from django.contrib.sessions.models import Session |
3 | 3 | from django.core.exceptions import SuspiciousOperation |
4 | | from django.utils.cache import patch_vary_headers |
| 4 | from django.cache.utils import patch_vary_headers |
5 | 5 | import datetime |
6 | 6 | |
7 | 7 | TEST_COOKIE_NAME = 'testcookie' |
=== modified file 'django/middleware/gzip.py'
|
|
|
1 | 1 | import re |
2 | 2 | from django.utils.text import compress_string |
3 | | from django.utils.cache import patch_vary_headers |
| 3 | from django.cache.utils import patch_vary_headers |
4 | 4 | |
5 | 5 | re_accepts_gzip = re.compile(r'\bgzip\b') |
6 | 6 | |
=== modified file 'django/middleware/locale.py'
|
|
|
1 | 1 | "this is the locale selecting middleware that will look at accept headers" |
2 | 2 | |
3 | | from django.utils.cache import patch_vary_headers |
| 3 | from django.cache.utils import patch_vary_headers |
4 | 4 | from django.utils import translation |
5 | 5 | |
6 | 6 | class LocaleMiddleware(object): |
=== modified file 'django/views/decorators/vary.py'
|
|
|
1 | | from django.utils.cache import patch_vary_headers |
| 1 | from django.cache.utils import patch_vary_headers |
2 | 2 | |
3 | 3 | def vary_on_headers(*headers): |
4 | 4 | """ |
=== modified file 'docs/cache.txt'
|
|
|
294 | 294 | intensive database query. In cases like this, you can use the low-level cache |
295 | 295 | API to store objects in the cache with any level of granularity you like. |
296 | 296 | |
297 | | The cache API is simple. The cache module, ``django.core.cache``, exports a |
| 297 | The cache API is simple. The cache module, ``django.cache``, exports a |
298 | 298 | ``cache`` object that's automatically created from the ``CACHE_BACKEND`` |
299 | 299 | setting:: |
300 | 300 | |
301 | | >>> from django.core.cache import cache |
| 301 | >>> from django.cache import cache |
302 | 302 | |
303 | 303 | The basic interface is ``set(key, value, timeout_seconds)`` and ``get(key)``:: |
304 | 304 | |
=== modified file 'tests/regressiontests/cache/tests.py'
|
|
|
1 | 1 | # Unit tests for cache framework |
2 | 2 | # Uses whatever cache backend is set in the test settings file. |
3 | 3 | |
4 | | from django.core.cache import cache |
| 4 | from django.cache import cache |
5 | 5 | import time, unittest |
6 | 6 | |
7 | 7 | # functions/classes for complex data type tests |