Ticket #7398: importable-backends.diff
File importable-backends.diff, 4.2 KB (added by , 16 years ago) |
---|
-
docs/cache.txt
182 182 various places but a development/test environment on which you don't want to 183 183 cache. As a result, your development environment won't use caching and your 184 184 production environment still will. To activate dummy caching, set 185 ``CACHE_BACKEND`` like so: :185 ``CACHE_BACKEND`` like so: 186 186 187 187 CACHE_BACKEND = 'dummy:///' 188 188 189 Using your own cache backend 190 ---------------------------- 191 192 **New in Django development version** 193 194 While Django includes support for many cache backends out-of-the-box, sometimes 195 that just isn't enough. Consider, for instance, Google App Engine. Google 196 will host your Django for you, but to maintain a safe and stable platform, it 197 replaces a few common modules like memcached and PIL with its own variants. 198 Fear not; Django makes it easy to include third-party backends in case the 199 included ones just won't cut the mustard. All you need to do is supply the 200 full Python path to the backend in the ``CACHE_BACKEND`` setting, like so: 201 202 CACHE_BACKEND = 'path.to.cache_backend:///' 203 204 Make sure, of course, that ``path.to.cache_backend`` is a valid Django backend. If 205 you're building your own backend, you can use the baked-in cache backends as 206 reference. You'll find them at ``django.core.cache.backends``. 207 208 Note: Without a really compelling reason, like a host that doesn't support the 209 them, you should stick to the ones included with Django. They've been really 210 well-tested and are quite easy to use. 211 189 212 CACHE_BACKEND arguments 190 213 ----------------------- 191 214 -
AUTHORS
227 227 Stuart Langridge <http://www.kryogenix.org/> 228 228 Paul Lanier <planier@google.com> 229 229 Nicola Larosa <nico@teknico.net> 230 Lau Bech Lauritzen 230 231 Rune Rønde Laursen <runerl@skjoldhoej.dk> 231 232 Eugene Lazutkin <http://lazutkin.com/blog/> 232 233 lcordier@point45.com … … 323 324 Pete Shinners <pete@shinners.org> 324 325 Leo Shklovskii 325 326 jason.sidabras@gmail.com 327 Brenton Simpson <http://theillustratedlife.com> 326 328 Jozko Skrablin <jozko.skrablin@gmail.com> 327 329 Ben Slavin <benjamin.slavin@gmail.com> 328 330 SmileyChris <smileychris@gmail.com> -
django/core/cache/__init__.py
21 21 22 22 BACKENDS = { 23 23 # name for use in settings file --> name of module in "backends" directory 24 'memcached': ' memcached',25 'locmem': ' locmem',26 'file': ' filebased',27 'db': 'd b',28 'dummy': 'd ummy',24 'memcached': 'django.core.cache.backends.memcached', 25 'locmem': 'django.core.cache.backends.locmem', 26 'file': 'django.core.cache.backends.filebased', 27 'db': 'django.core.cache.backends.db', 28 'dummy': 'django.core.cache.backends.dummy', 29 29 } 30 30 31 31 DEPRECATED_BACKENDS = { … … 44 44 warnings.warn("'%s' backend is deprecated. Use '%s' instead." % 45 45 (scheme, DEPRECATED_BACKENDS[scheme]), DeprecationWarning) 46 46 scheme = DEPRECATED_BACKENDS[scheme] 47 if scheme not in BACKENDS:48 raise InvalidCacheBackendError, "%r is not a valid cache backend" % scheme49 47 50 48 host = rest[2:] 51 49 qpos = rest.find('?') … … 56 54 params = {} 57 55 if host.endswith('/'): 58 56 host = host[:-1] 59 60 cache_class = getattr(__import__('django.core.cache.backends.%s' % BACKENDS[scheme], {}, {}, ['']), 'CacheClass') 57 58 backend_path = scheme 59 if scheme in BACKENDS: 60 backend_path = BACKENDS[scheme] 61 try: 62 backend_import = __import__(backend_path, {}, {}, ['']) 63 except ImportError: 64 raise InvalidCacheBackendError, "Cache backend "+backend_path+" cannot be found." 65 66 cache_class = getattr(backend_import, 'CacheClass') 61 67 return cache_class(host, params) 62 68