Changeset 6857
- Timestamp:
- 12/02/07 20:59:56 (1 year ago)
- Files:
-
- django/branches/queryset-refactor/AUTHORS (modified) (8 diffs)
- django/branches/queryset-refactor/django/conf/global_settings.py (modified) (2 diffs)
- django/branches/queryset-refactor/django/conf/__init__.py (modified) (3 diffs)
- django/branches/queryset-refactor/django/conf/locale/ca/LC_MESSAGES/djangojs.mo (modified) (previous)
- django/branches/queryset-refactor/django/conf/locale/ca/LC_MESSAGES/djangojs.po (modified) (4 diffs)
- django/branches/queryset-refactor/django/contrib/admin/templates/admin/field_line.html (modified) (1 diff)
- django/branches/queryset-refactor/django/contrib/localflavor/mx (added)
- django/branches/queryset-refactor/django/contrib/localflavor/mx/forms.py (added)
- django/branches/queryset-refactor/django/contrib/localflavor/mx/__init__.py (added)
- django/branches/queryset-refactor/django/contrib/localflavor/mx/mx_states.py (added)
- django/branches/queryset-refactor/django/contrib/localflavor/uk/forms.py (modified) (2 diffs)
- django/branches/queryset-refactor/django/contrib/localflavor/uk/uk_regions.py (added)
- django/branches/queryset-refactor/django/contrib/localflavor/za (added)
- django/branches/queryset-refactor/django/contrib/localflavor/za/forms.py (added)
- django/branches/queryset-refactor/django/contrib/localflavor/za/__init__.py (added)
- django/branches/queryset-refactor/django/contrib/localflavor/za/za_provinces.py (added)
- django/branches/queryset-refactor/django/contrib/markup/templatetags/markup.py (modified) (2 diffs)
- django/branches/queryset-refactor/django/contrib/markup/tests.py (modified) (1 diff)
- django/branches/queryset-refactor/django/contrib/sessions/backends/base.py (modified) (1 diff)
- django/branches/queryset-refactor/django/contrib/sessions/models.py (modified) (1 diff)
- django/branches/queryset-refactor/django/contrib/sessions/tests.py (modified) (1 diff)
- django/branches/queryset-refactor/django/core/cache/backends/base.py (modified) (5 diffs)
- django/branches/queryset-refactor/django/core/cache/backends/filebased.py (modified) (2 diffs)
- django/branches/queryset-refactor/django/core/cache/backends/locmem.py (modified) (5 diffs)
- django/branches/queryset-refactor/django/core/cache/backends/simple.py (deleted)
- django/branches/queryset-refactor/django/core/cache/__init__.py (modified) (2 diffs)
- django/branches/queryset-refactor/django/core/exceptions.py (modified) (1 diff)
- django/branches/queryset-refactor/django/core/handlers/base.py (modified) (1 diff)
- django/branches/queryset-refactor/django/core/handlers/modpython.py (modified) (1 diff)
- django/branches/queryset-refactor/django/core/handlers/wsgi.py (modified) (1 diff)
- django/branches/queryset-refactor/django/core/management/base.py (modified) (1 diff)
- django/branches/queryset-refactor/django/core/management/commands/syncdb.py (modified) (1 diff)
- django/branches/queryset-refactor/django/core/management/__init__.py (modified) (3 diffs)
- django/branches/queryset-refactor/django/core/management/validation.py (modified) (2 diffs)
- django/branches/queryset-refactor/django/core/servers/basehttp.py (modified) (6 diffs)
- django/branches/queryset-refactor/django/db/backends/oracle/base.py (modified) (1 diff)
- django/branches/queryset-refactor/django/db/backends/postgresql_psycopg2/base.py (modified) (2 diffs)
- django/branches/queryset-refactor/django/db/models/base.py (modified) (2 diffs)
- django/branches/queryset-refactor/django/db/models/fields/__init__.py (modified) (1 diff)
- django/branches/queryset-refactor/django/db/models/options.py (modified) (3 diffs)
- django/branches/queryset-refactor/django/db/models/query.py (modified) (1 diff)
- django/branches/queryset-refactor/django/http/utils.py (modified) (3 diffs)
- django/branches/queryset-refactor/django/middleware/common.py (modified) (3 diffs)
- django/branches/queryset-refactor/django/newforms/fields.py (modified) (2 diffs)
- django/branches/queryset-refactor/django/newforms/models.py (modified) (6 diffs)
- django/branches/queryset-refactor/django/shortcuts/__init__.py (modified) (1 diff)
- django/branches/queryset-refactor/django/template/context.py (modified) (2 diffs)
- django/branches/queryset-refactor/django/template/defaultfilters.py (modified) (1 diff)
- django/branches/queryset-refactor/django/template/__init__.py (modified) (1 diff)
- django/branches/queryset-refactor/django/test/_doctest.py (modified) (1 diff)
- django/branches/queryset-refactor/django/utils/datastructures.py (modified) (3 diffs)
- django/branches/queryset-refactor/django/utils/html.py (modified) (1 diff)
- django/branches/queryset-refactor/django/utils/maxlength.py (modified) (1 diff)
- django/branches/queryset-refactor/django/utils/safestring.py (modified) (2 diffs)
- django/branches/queryset-refactor/django/views/debug.py (modified) (5 diffs)
- django/branches/queryset-refactor/django/views/generic/date_based.py (modified) (1 diff)
- django/branches/queryset-refactor/django/views/generic/list_detail.py (modified) (1 diff)
- django/branches/queryset-refactor/django/views/static.py (modified) (1 diff)
- django/branches/queryset-refactor/docs/add_ons.txt (modified) (4 diffs)
- django/branches/queryset-refactor/docs/authentication.txt (modified) (3 diffs)
- django/branches/queryset-refactor/docs/cache.txt (modified) (6 diffs)
- django/branches/queryset-refactor/docs/contributing.txt (modified) (3 diffs)
- django/branches/queryset-refactor/docs/custom_model_fields.txt (modified) (26 diffs)
- django/branches/queryset-refactor/docs/databases.txt (modified) (6 diffs)
- django/branches/queryset-refactor/docs/email.txt (modified) (1 diff)
- django/branches/queryset-refactor/docs/form_for_model.txt (added)
- django/branches/queryset-refactor/docs/generic_views.txt (modified) (2 diffs)
- django/branches/queryset-refactor/docs/i18n.txt (modified) (1 diff)
- django/branches/queryset-refactor/docs/install.txt (modified) (1 diff)
- django/branches/queryset-refactor/docs/localflavor.txt (added)
- django/branches/queryset-refactor/docs/middleware.txt (modified) (1 diff)
- django/branches/queryset-refactor/docs/model-api.txt (modified) (1 diff)
- django/branches/queryset-refactor/docs/modelforms.txt (added)
- django/branches/queryset-refactor/docs/modpython.txt (modified) (1 diff)
- django/branches/queryset-refactor/docs/newforms.txt (modified) (9 diffs)
- django/branches/queryset-refactor/docs/request_response.txt (modified) (2 diffs)
- django/branches/queryset-refactor/docs/serialization.txt (modified) (2 diffs)
- django/branches/queryset-refactor/docs/sessions.txt (modified) (1 diff)
- django/branches/queryset-refactor/docs/settings.txt (modified) (4 diffs)
- django/branches/queryset-refactor/docs/shortcuts.txt (modified) (1 diff)
- django/branches/queryset-refactor/docs/syndication_feeds.txt (modified) (2 diffs)
- django/branches/queryset-refactor/docs/templates_python.txt (modified) (6 diffs)
- django/branches/queryset-refactor/docs/templates.txt (modified) (6 diffs)
- django/branches/queryset-refactor/docs/tutorial02.txt (modified) (14 diffs)
- django/branches/queryset-refactor/docs/unicode.txt (modified) (1 diff)
- django/branches/queryset-refactor/tests/modeltests/empty/models.py (modified) (1 diff)
- django/branches/queryset-refactor/tests/modeltests/field_defaults/models.py (modified) (1 diff)
- django/branches/queryset-refactor/tests/modeltests/get_object_or_404/models.py (modified) (1 diff)
- django/branches/queryset-refactor/tests/modeltests/invalid_models/models.py (modified) (2 diffs)
- django/branches/queryset-refactor/tests/modeltests/model_forms/models.py (modified) (26 diffs)
- django/branches/queryset-refactor/tests/modeltests/select_related/models.py (modified) (1 diff)
- django/branches/queryset-refactor/tests/modeltests/serializers/models.py (modified) (1 diff)
- django/branches/queryset-refactor/tests/modeltests/test_client/models.py (modified) (1 diff)
- django/branches/queryset-refactor/tests/modeltests/user_commands/models.py (modified) (1 diff)
- django/branches/queryset-refactor/tests/regressiontests/cache/tests.py (modified) (1 diff)
- django/branches/queryset-refactor/tests/regressiontests/forms/localflavor/za.py (added)
- django/branches/queryset-refactor/tests/regressiontests/forms/tests.py (modified) (2 diffs)
- django/branches/queryset-refactor/tests/regressiontests/i18n/tests.py (modified) (2 diffs)
- django/branches/queryset-refactor/tests/regressiontests/middleware (added)
- django/branches/queryset-refactor/tests/regressiontests/middleware/__init__.py (added)
- django/branches/queryset-refactor/tests/regressiontests/middleware/tests.py (added)
- django/branches/queryset-refactor/tests/regressiontests/middleware/urls.py (added)
- django/branches/queryset-refactor/tests/regressiontests/string_lookup/models.py (modified) (4 diffs)
- django/branches/queryset-refactor/tests/regressiontests/templates/context.py (added)
- django/branches/queryset-refactor/tests/regressiontests/templates/tests.py (modified) (2 diffs)
- django/branches/queryset-refactor/tests/regressiontests/templates/unicode.py (modified) (2 diffs)
- django/branches/queryset-refactor/tests/regressiontests/views/views.py (modified) (1 diff)
- django/branches/queryset-refactor/tests/runtests.py (modified) (1 diff)
- django/branches/queryset-refactor/tests/urls.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/queryset-refactor/AUTHORS
r6753 r6857 90 90 Pete Crosier <pete.crosier@gmail.com> 91 91 Matt Croydon <http://www.postneo.com/> 92 Leah Culver <leah@pownce.com> 92 93 flavio.curella@gmail.com 93 94 Jure Cuhalev <gandalf@owca.info> … … 133 134 gandalf@owca.info 134 135 Marc Garcia <marc.garcia@accopensys.com> 136 Andy Gayton <andy-django@thecablelounge.com> 135 137 Baishampayan Ghose 136 138 Dimitris Glezos <dimitris@glezos.com> … … 172 174 Antti Kaihola <http://akaihola.blogspot.com/> 173 175 Nagy Károly <charlie@rendszergazda.com> 176 Erik Karulf <erik@karulf.com> 174 177 Ben Dean Kawamura <ben.dean.kawamura@gmail.com> 175 178 Ian G. Kelly <ian.g.kelly@gmail.com> … … 191 194 konrad@gwu.edu 192 195 knox <christobzr@gmail.com> 196 David Krauth 193 197 kurtiss@meetro.com 194 198 lakin.wecker@gmail.com … … 205 209 limodou 206 210 Philip Lindborg <philip.lindborg@gmail.com> 211 Trey Long <trey@ktrl.com> 207 212 msaelices <msaelices@gmail.com> 208 213 Matt McClanahan <http://mmcc.cx/> … … 253 258 Luke Plant <http://lukeplant.me.uk/> 254 259 plisk 260 Mihai Preda <mihai_preda@yahoo.com> 255 261 Daniel Poelzleithner <http://poelzi.org/> 256 262 polpak@yahoo.com … … 264 270 Brian Ray <http://brianray.chipy.org/> 265 271 remco@diji.biz 272 David Reynolds <david@reynoldsfamily.org.uk> 266 273 rhettg@gmail.com 267 274 ricardojbarrios@gmail.com … … 283 290 jason.sidabras@gmail.com 284 291 Jozko Skrablin <jozko.skrablin@gmail.com> 292 Ben Slavin <benjamin.slavin@gmail.com> 285 293 SmileyChris <smileychris@gmail.com> 286 294 smurf@smurf.noris.de django/branches/queryset-refactor/django/conf/global_settings.py
r6726 r6857 254 254 URL_VALIDATOR_USER_AGENT = "Django/%s (http://www.djangoproject.com)" % get_version() 255 255 256 # The tablespaces to use for each model when not specified otherwise. 257 DEFAULT_TABLESPACE = '' 258 DEFAULT_INDEX_TABLESPACE = '' 259 256 260 ############## 257 261 # MIDDLEWARE # … … 290 294 # The cache backend to use. See the docstring in django.core.cache for the 291 295 # possible values. 292 CACHE_BACKEND = ' simple://'296 CACHE_BACKEND = 'locmem://' 293 297 CACHE_MIDDLEWARE_KEY_PREFIX = '' 294 298 CACHE_MIDDLEWARE_SECONDS = 600 django/branches/queryset-refactor/django/conf/__init__.py
r6597 r6857 53 53 raise KeyError 54 54 except KeyError: 55 raise EnvironmentError, "Environment variable %s is undefined." % ENVIRONMENT_VARIABLE55 raise ImportError, "Environment variable %s is undefined so settings cannot be imported." % ENVIRONMENT_VARIABLE # NOTE: This is arguably an EnvironmentError, but that causes problems with Python's interactive help 56 56 57 57 self._target = Settings(settings_module) … … 64 64 """ 65 65 if self._target != None: 66 raise EnvironmentError, 'Settings already configured.'66 raise RuntimeError, 'Settings already configured.' 67 67 holder = UserSettingsHolder(default_settings) 68 68 for name, value in options.items(): … … 83 83 mod = __import__(self.SETTINGS_MODULE, {}, {}, ['']) 84 84 except ImportError, e: 85 raise EnvironmentError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)85 raise ImportError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e) 86 86 87 87 # Settings that should be converted into tuples if they're mistakenly entered django/branches/queryset-refactor/django/conf/locale/ca/LC_MESSAGES/djangojs.po
r5539 r6857 1 # translation of djangojs.po to español 1 2 # translation of djangojs.po to 2 3 # Catalan translation for the django-admin JS files. 3 4 # This file is distributed under the same license as the Django package. 4 5 # 6 # Antoni Aloy <antoni.aloy@trespams.com>, 2007. 5 7 msgid "" 6 8 msgstr "" … … 8 10 "Report-Msgid-Bugs-To: \n" 9 11 "POT-Creation-Date: 2007-05-20 18:25+0200\n" 10 "PO-Revision-Date: 2007- 06-25 17:47+0200\n"11 "Last-Translator: Marc Fargas <telenieko@telenieko.com>\n"12 "Language-Team: <es@li.org>\n"12 "PO-Revision-Date: 2007-12-01 12:06+0100\n" 13 "Last-Translator: Antoni Aloy <antoni.aloy@trespams.com>\n" 14 "Language-Team: español <ca@li.org>\n" 13 15 "MIME-Version: 1.0\n" 14 16 "Content-Type: text/plain; charset=UTF-8\n" 15 17 "Content-Transfer-Encoding: 8bit\n" 16 "X-Generator: VIM 7.0\n"18 "X-Generator: KBabel 1.11.4\n" 17 19 "Plural-Forms: nplurals=2; plural=(n != 1);\n" 18 20 … … 52 54 "January February March April May June July August September October November " 53 55 "December" 54 msgstr "" 55 "Febrer Març Abril Maig Juny Juliol Agost Setembre Octubre Novembre Desembre" 56 msgstr "Gener Febrer Març Abril Maig Juny Juliol Agost Setembre Octubre Novembre Desembre" 56 57 57 58 #: contrib/admin/media/js/dateparse.js:33 … … 118 119 msgid "Hide" 119 120 msgstr "Ocultar" 121 django/branches/queryset-refactor/django/contrib/admin/templates/admin/field_line.html
r3037 r6857 6 6 {% field_widget bound_field %} 7 7 {% if not bound_field.has_label_first %}{% field_label bound_field %}{% endif %} 8 {% if bound_field.field.help_text %}<p class="help">{{ bound_field.field.help_text }}</p>{% endif %}8 {% if bound_field.field.help_text %}<p class="help">{{ bound_field.field.help_text|safe }}</p>{% endif %} 9 9 {% endfor %} 10 10 </div> django/branches/queryset-refactor/django/contrib/localflavor/uk/forms.py
r5876 r6857 3 3 """ 4 4 5 from django.newforms.fields import RegexField 5 from django.newforms.fields import RegexField, Select 6 6 from django.utils.translation import ugettext 7 7 … … 18 18 error_message=ugettext(u'Enter a postcode. A space is required between the two postcode parts.'), 19 19 *args, **kwargs) 20 21 class UKCountySelect(Select): 22 """ 23 A Select widget that uses a list of UK Counties/Regions as its choices. 24 """ 25 def __init__(self, attrs=None): 26 from uk_regions import UK_REGION_CHOICES 27 super(UKCountySelect, self).__init__(attrs, choices=UK_REGION_CHOICES) 28 29 class UKNationSelect(Select): 30 """ 31 A Select widget that uses a list of UK Nations as its choices. 32 """ 33 def __init__(self, attrs=None): 34 from uk_regions import UK_NATIONS_CHOICES 35 super(UKNationSelect, self).__init__(attrs, choices=UK_NATIONS_CHOICES) django/branches/queryset-refactor/django/contrib/markup/templatetags/markup.py
r6690 r6857 33 33 textile.is_safe = True 34 34 35 def markdown(value): 35 def markdown(value, arg=''): 36 """ 37 Runs Markdown over a given value, optionally using various 38 extensions python-markdown supports. 39 40 Syntax:: 41 42 {{ value|markdown:"extension1_name,extension2_name..." }} 43 44 To enable safe mode, which strips raw HTML and only returns HTML 45 generated by actual Markdown syntax, pass "safe" as the first 46 extension in the list. 47 48 If the version of Markdown in use does not support extensions, 49 they will be silently ignored. 50 51 """ 36 52 try: 37 53 import markdown … … 41 57 return force_unicode(value) 42 58 else: 43 return mark_safe(force_unicode(markdown.markdown(smart_str(value)))) 59 # markdown.version was first added in 1.6b. The only version of markdown 60 # to fully support extensions before 1.6b was the shortlived 1.6a. 61 if hasattr(markdown, 'version'): 62 extensions = [e for e in arg.split(",") if e] 63 if len(extensions) > 0 and extensions[0] == "safe": 64 extensions = extensions[1:] 65 safe_mode = True 66 else: 67 safe_mode = False 68 return mark_safe(force_unicode(markdown.markdown(smart_str(value), extensions, safe_mode=safe_mode))) 69 else: 70 return mark_safe(force_unicode(markdown.markdown(smart_str(value)))) 44 71 markdown.is_safe = True 45 72 django/branches/queryset-refactor/django/contrib/markup/tests.py
r6690 r6857 62 62 rendered = t.render(Context(locals())).strip() 63 63 if docutils: 64 self.assertEqual(rendered, """<p>Paragraph 1</p> 64 # Different versions of docutils return slightly different HTML 65 try: 66 # Docutils v0.4 and earlier 67 self.assertEqual(rendered, """<p>Paragraph 1</p> 65 68 <p>Paragraph 2 with a <a class="reference" href="http://www.example.com/">link</a></p>""") 69 except AssertionError, e: 70 # Docutils from SVN (which will become 0.5) 71 self.assertEqual(rendered, """<p>Paragraph 1</p> 72 <p>Paragraph 2 with a <a class="reference external" href="http://www.example.com/">link</a></p>""") 66 73 else: 67 74 self.assertEqual(rendered, rest_content) django/branches/queryset-refactor/django/contrib/sessions/backends/base.py
r6597 r6857 51 51 self.modified = self.modified or key in self._session 52 52 return self._session.pop(key, *args) 53 54 def setdefault(self, key, value): 55 if key in self._session: 56 return self._session[key] 57 else: 58 self.modified = True 59 self._session[key] = value 60 return value 53 61 54 62 def set_test_cookie(self): django/branches/queryset-refactor/django/contrib/sessions/models.py
r6466 r6857 18 18 pickled_md5 = md5.new(pickled + settings.SECRET_KEY).hexdigest() 19 19 return base64.encodestring(pickled + pickled_md5) 20 21 def get_new_session_key(self):22 "Returns session key that isn't being used."23 # The random module is seeded when this Apache child is created.24 # Use SECRET_KEY as added salt.25 try:26 pid = os.getpid()27 except AttributeError:28 # No getpid() in Jython, for example29 pid = 130 while 1:31 session_key = md5.new("%s%s%s%s" % (random.randint(0, sys.maxint - 1), pid, time.time(), settings.SECRET_KEY)).hexdigest()32 try:33 self.get(session_key=session_key)34 except self.model.DoesNotExist:35 break36 return session_key37 38 def get_new_session_object(self):39 """40 Returns a new session object.41 """42 # FIXME: There is a *small* chance of collision here, meaning we will43 # return an existing object. That can be fixed when we add a way to44 # validate (and guarantee) that non-auto primary keys are unique. For45 # now, we save immediately in order to reduce the "window of46 # misfortune" as much as possible.47 created = False48 while not created:49 obj, created = self.get_or_create(session_key=self.get_new_session_key(),50 expire_date = datetime.datetime.now())51 # Collision in key generation, so re-seed the generator52 random.seed()53 return obj54 20 55 21 def save(self, session_key, session_dict, expire_date): django/branches/queryset-refactor/django/contrib/sessions/tests.py
r6597 r6857 67 67 (True, False) 68 68 69 >>> s.setdefault('foo', 'bar') 70 'bar' 71 >>> s.setdefault('foo', 'baz') 72 'bar' 73 69 74 >>> s.accessed = False # Reset the accessed flag 70 75 django/branches/queryset-refactor/django/core/cache/backends/base.py
r6597 r6857 17 17 def add(self, key, value, timeout=None): 18 18 """ 19 Set a value in the cache if the key does not already exist. If19 Set a value in the cache if the key does not already exist. If 20 20 timeout is given, that timeout will be used for the key; otherwise 21 21 the default cache timeout will be used. … … 25 25 def get(self, key, default=None): 26 26 """ 27 Fetch a given key from the cache. If the key does not exist, return27 Fetch a given key from the cache. If the key does not exist, return 28 28 default, which itself defaults to None. 29 29 """ … … 32 32 def set(self, key, value, timeout=None): 33 33 """ 34 Set a value in the cache. If timeout is given, that timeout will be34 Set a value in the cache. If timeout is given, that timeout will be 35 35 used for the key; otherwise the default cache timeout will be used. 36 36 """ … … 45 45 def get_many(self, keys): 46 46 """ 47 Fetch a bunch of keys from the cache. For certain backends (memcached,47 Fetch a bunch of keys from the cache. For certain backends (memcached, 48 48 pgsql) this can be *much* faster when fetching multiple values. 49 49 50 Returns a dict mapping each key in keys to its value. If the given50 Returns a dict mapping each key in keys to its value. If the given 51 51 key is missing, it will be missing from the response dict. 52 52 """ … … 65 65 66 66 __contains__ = has_key 67 django/branches/queryset-refactor/django/core/cache/backends/filebased.py
r6597 r6857 1 1 "File-based cache backend" 2 2 3 from django.core.cache.backends.simple import CacheClass as SimpleCacheClass4 from django.utils.http import urlquote_plus5 3 import os, time 6 4 try: … … 8 6 except ImportError: 9 7 import pickle 8 from django.core.cache.backends.base import BaseCache 9 from django.utils.http import urlquote_plus 10 10 11 class CacheClass( SimpleCacheClass):11 class CacheClass(BaseCache): 12 12 def __init__(self, dir, params): 13 BaseCache.__init__(self, params) 14 15 max_entries = params.get('max_entries', 300) 16 try: 17 self._max_entries = int(max_entries) 18 except (ValueError, TypeError): 19 self._max_entries = 300 20 21 cull_frequency = params.get('cull_frequency', 3) 22 try: 23 self._cull_frequency = int(cull_frequency) 24 except (ValueError, TypeError): 25 self._cull_frequency = 3 26 13 27 self._dir = dir 14 28 if not os.path.exists(self._dir): 15 29 self._createdir() 16 SimpleCacheClass.__init__(self, dir, params)17 del self._cache18 del self._expire_info19 30 20 31 def add(self, key, value, timeout=None): django/branches/queryset-refactor/django/core/cache/backends/locmem.py
r6726 r6857 7 7 import pickle 8 8 9 from django.core.cache.backends. simple import CacheClass as SimpleCacheClass9 from django.core.cache.backends.base import BaseCache 10 10 from django.utils.synch import RWLock 11 11 12 class CacheClass(SimpleCacheClass): 13 def __init__(self, host, params): 14 SimpleCacheClass.__init__(self, host, params) 12 class CacheClass(BaseCache): 13 def __init__(self, _, params): 14 BaseCache.__init__(self, params) 15 self._cache = {} 16 self._expire_info = {} 17 18 max_entries = params.get('max_entries', 300) 19 try: 20 self._max_entries = int(max_entries) 21 except (ValueError, TypeError): 22 self._max_entries = 300 23 24 cull_frequency = params.get('cull_frequency', 3) 25 try: 26 self._cull_frequency = int(cull_frequency) 27 except (ValueError, TypeError): 28 self._cull_frequency = 3 29 15 30 self._lock = RWLock() 31 32 def _add(self, key, value, timeout=None): 33 if len(self._cache) >= self._max_entries: 34 self._cull() 35 if timeout is None: 36 timeout = self.default_timeout 37 if key not in self._cache.keys(): 38 self._cache[key] = value 39 self._expire_info[key] = time.time() + timeout 16 40 17 41 def add(self, key, value, timeout=None): … … 20 44 try: 21 45 try: 22 s uper(CacheClass, self).add(key, pickle.dumps(value), timeout)46 self._add(key, pickle.dumps(value), timeout) 23 47 except pickle.PickleError: 24 48 pass … … 52 76 self._lock.writer_leaves() 53 77 78 def _set(self, key, value, timeout=None): 79 if len(self._cache) >= self._max_entries: 80 self._cull() 81 if timeout is None: 82 timeout = self.default_timeout 83 self._cache[key] = value 84 self._expire_info[key] = time.time() + timeout 85 54 86 def set(self, key, value, timeout=None): 55 87 self._lock.writer_enters() … … 57 89 try: 58 90 try: 59 s uper(CacheClass, self).set(key, pickle.dumps(value), timeout)91 self._set(key, pickle.dumps(value), timeout) 60 92 except pickle.PickleError: 61 93 pass … … 63 95 self._lock.writer_leaves() 64 96 97 def has_key(self, key): 98 return key in self._cache 99 100 def _cull(self): 101 if self._cull_frequency == 0: 102 self._cache.clear() 103 self._expire_info.clear() 104 else: 105 doomed = [k for (i, k) in enumerate(self._cache) if i % self._cull_frequency == 0] 106 for k in doomed: 107 self.delete(k) 108 109 def _delete(self, key): 110 try: 111 del self._cache[key] 112 except KeyError: 113 pass 114 try: 115 del self._expire_info[key] 116 except KeyError: 117 pass 118 65 119 def delete(self, key): 66 120 self._lock.writer_enters() 67 121 try: 68 SimpleCacheClass.delete(self,key)122 self._delete(key) 69 123 finally: 70 124 self._lock.writer_leaves() django/branches/queryset-refactor/django/core/cache/__init__.py
r4486 r6857 23 23 # name for use in settings file --> name of module in "backends" directory 24 24 'memcached': 'memcached', 25 'simple': 'simple',26 25 'locmem': 'locmem', 27 26 'file': 'filebased', 28 27 'db': 'db', 29 28 'dummy': 'dummy', 29 } 30 31 DEPRECATED_BACKENDS = { 32 # deprecated backend --> replacement module 33 'simple': 'locmem', 30 34 } 31 35 … … 36 40 if not rest.startswith('//'): 37 41 raise InvalidCacheBackendError, "Backend URI must start with scheme://" 42 if scheme in DEPRECATED_BACKENDS: 43 import warnings 44 warnings.warn("'%s' backend is deprecated. Use '%s' instead." % 45 (scheme, DEPRECATED_BACKENDS[scheme]), DeprecationWarning) 46 scheme = DEPRECATED_BACKENDS[scheme] 38 47 if scheme not in BACKENDS: 39 48 raise InvalidCacheBackendError, "%r is not a valid cache backend" % scheme django/branches/queryset-refactor/django/core/exceptions.py
r2809 r6857 4 4 "The requested object does not exist" 5 5 silent_variable_failure = True 6 7 class MultipleObjectsReturned(Exception): 8 "The query returned multiple objects when only one was expected." 9 pass 6 10 7 11 class SuspiciousOperation(Exception): django/branches/queryset-refactor/django/core/handlers/base.py
r6690 r6857 1 import sys 2 3 from django import http 1 4 from django.core import signals 2 5 from django.dispatch import dispatcher 3 from django import http4 import sys5 6 6 7 class BaseHandler(object): django/branches/queryset-refactor/django/core/handlers/modpython.py
r6690 r6857 1 import os 2 from pprint import pformat 3 4 from django import http 5 from django.core import signals 1 6 from django.core.handlers.base import BaseHandler 2 from django.core import signals3 7 from django.dispatch import dispatcher 4 8 from django.utils import datastructures 5 9 from django.utils.encoding import force_unicode 6 from django import http7 from pprint import pformat8 import os9 10 10 11 # NOTE: do *not* import settings (or any module which eventually imports django/branches/queryset-refactor/django/core/handlers/wsgi.py
r6690 r6857 6 6 from StringIO import StringIO 7 7 8 from django import http 9 from django.core import signals 8 10 from django.core.handlers.base import BaseHandler 9 from django.core import signals10 11 from django.dispatch import dispatcher 11 12 from django.utils import datastructures 12 13 from django.utils.encoding import force_unicode 13 from django import http14 14 15 15 # See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html django/branches/queryset-refactor/django/core/management/base.py
r6597 r6857 173 173 Copies either a Django application layout template or a Django project 174 174 layout template into the specified directory. 175 176 * style - A color style object (see django.core.management.color). 177 * app_or_project - The string 'app' or 'project'. 178 * name - The name of the application or project. 179 * directory - The directory to copy the layout template to. 180 <
