Changeset 6864
- Timestamp:
- 12/03/07 11:37:33 (9 months ago)
- Files:
-
- django/branches/newforms-admin (modified) (1 prop)
- django/branches/newforms-admin/AUTHORS (modified) (8 diffs)
- django/branches/newforms-admin/django/conf/global_settings.py (modified) (2 diffs)
- django/branches/newforms-admin/django/conf/__init__.py (modified) (3 diffs)
- django/branches/newforms-admin/django/conf/locale/ca/LC_MESSAGES/djangojs.mo (modified) (previous)
- django/branches/newforms-admin/django/conf/locale/ca/LC_MESSAGES/djangojs.po (modified) (4 diffs)
- django/branches/newforms-admin/django/contrib/localflavor/mx (copied) (copied from django/trunk/django/contrib/localflavor/mx)
- django/branches/newforms-admin/django/contrib/localflavor/mx/forms.py (copied) (copied from django/trunk/django/contrib/localflavor/mx/forms.py)
- django/branches/newforms-admin/django/contrib/localflavor/mx/__init__.py (copied) (copied from django/trunk/django/contrib/localflavor/mx/__init__.py)
- django/branches/newforms-admin/django/contrib/localflavor/mx/mx_states.py (copied) (copied from django/trunk/django/contrib/localflavor/mx/mx_states.py)
- django/branches/newforms-admin/django/contrib/localflavor/uk/forms.py (modified) (2 diffs)
- django/branches/newforms-admin/django/contrib/localflavor/uk/uk_regions.py (copied) (copied from django/trunk/django/contrib/localflavor/uk/uk_regions.py)
- django/branches/newforms-admin/django/contrib/localflavor/za (copied) (copied from django/trunk/django/contrib/localflavor/za)
- django/branches/newforms-admin/django/contrib/localflavor/za/forms.py (copied) (copied from django/trunk/django/contrib/localflavor/za/forms.py)
- django/branches/newforms-admin/django/contrib/localflavor/za/__init__.py (copied) (copied from django/trunk/django/contrib/localflavor/za/__init__.py)
- django/branches/newforms-admin/django/contrib/localflavor/za/za_provinces.py (copied) (copied from django/trunk/django/contrib/localflavor/za/za_provinces.py)
- django/branches/newforms-admin/django/contrib/markup/templatetags/markup.py (modified) (2 diffs)
- django/branches/newforms-admin/django/contrib/markup/tests.py (modified) (1 diff)
- django/branches/newforms-admin/django/contrib/sessions/backends/base.py (modified) (1 diff)
- django/branches/newforms-admin/django/contrib/sessions/models.py (modified) (1 diff)
- django/branches/newforms-admin/django/contrib/sessions/tests.py (modified) (1 diff)
- django/branches/newforms-admin/django/core/cache/backends/filebased.py (modified) (2 diffs)
- django/branches/newforms-admin/django/core/cache/backends/locmem.py (modified) (5 diffs)
- django/branches/newforms-admin/django/core/cache/backends/simple.py (deleted)
- django/branches/newforms-admin/django/core/cache/__init__.py (modified) (2 diffs)
- django/branches/newforms-admin/django/core/exceptions.py (modified) (1 diff)
- django/branches/newforms-admin/django/core/handlers/base.py (modified) (1 diff)
- django/branches/newforms-admin/django/core/handlers/modpython.py (modified) (1 diff)
- django/branches/newforms-admin/django/core/handlers/wsgi.py (modified) (1 diff)
- django/branches/newforms-admin/django/core/management/commands/syncdb.py (modified) (1 diff)
- django/branches/newforms-admin/django/core/management/__init__.py (modified) (3 diffs)
- django/branches/newforms-admin/django/core/management/validation.py (modified) (2 diffs)
- django/branches/newforms-admin/django/db/backends/oracle/base.py (modified) (1 diff)
- django/branches/newforms-admin/django/db/backends/postgresql_psycopg2/base.py (modified) (2 diffs)
- django/branches/newforms-admin/django/db/models/base.py (modified) (2 diffs)
- django/branches/newforms-admin/django/db/models/fields/__init__.py (modified) (1 diff)
- django/branches/newforms-admin/django/db/models/options.py (modified) (3 diffs)
- django/branches/newforms-admin/django/db/models/query.py (modified) (1 diff)
- django/branches/newforms-admin/django/http/utils.py (modified) (3 diffs)
- django/branches/newforms-admin/django/middleware/common.py (modified) (3 diffs)
- django/branches/newforms-admin/django/newforms/fields.py (modified) (2 diffs)
- django/branches/newforms-admin/django/newforms/models.py (modified) (5 diffs)
- django/branches/newforms-admin/django/shortcuts/__init__.py (modified) (1 diff)
- django/branches/newforms-admin/django/template/context.py (modified) (2 diffs)
- django/branches/newforms-admin/django/template/defaultfilters.py (modified) (1 diff)
- django/branches/newforms-admin/django/test/_doctest.py (modified) (1 diff)
- django/branches/newforms-admin/django/utils/datastructures.py (modified) (3 diffs)
- django/branches/newforms-admin/django/utils/html.py (modified) (1 diff)
- django/branches/newforms-admin/django/utils/maxlength.py (modified) (1 diff)
- django/branches/newforms-admin/django/utils/safestring.py (modified) (2 diffs)
- django/branches/newforms-admin/django/views/debug.py (modified) (5 diffs)
- django/branches/newforms-admin/django/views/generic/date_based.py (modified) (1 diff)
- django/branches/newforms-admin/django/views/generic/list_detail.py (modified) (1 diff)
- django/branches/newforms-admin/docs/add_ons.txt (modified) (4 diffs)
- django/branches/newforms-admin/docs/authentication.txt (modified) (3 diffs)
- django/branches/newforms-admin/docs/cache.txt (modified) (1 diff)
- django/branches/newforms-admin/docs/contributing.txt (modified) (3 diffs)
- django/branches/newforms-admin/docs/custom_model_fields.txt (modified) (26 diffs)
- django/branches/newforms-admin/docs/databases.txt (modified) (1 diff)
- django/branches/newforms-admin/docs/email.txt (modified) (1 diff)
- django/branches/newforms-admin/docs/form_for_model.txt (copied) (copied from django/trunk/docs/form_for_model.txt)
- django/branches/newforms-admin/docs/generic_views.txt (modified) (2 diffs)
- django/branches/newforms-admin/docs/install.txt (modified) (1 diff)
- django/branches/newforms-admin/docs/localflavor.txt (copied) (copied from django/trunk/docs/localflavor.txt)
- django/branches/newforms-admin/docs/middleware.txt (modified) (1 diff)
- django/branches/newforms-admin/docs/model-api.txt (modified) (1 diff)
- django/branches/newforms-admin/docs/modelforms.txt (copied) (copied from django/trunk/docs/modelforms.txt)
- django/branches/newforms-admin/docs/newforms.txt (modified) (7 diffs)
- django/branches/newforms-admin/docs/request_response.txt (modified) (2 diffs)
- django/branches/newforms-admin/docs/serialization.txt (modified) (2 diffs)
- django/branches/newforms-admin/docs/sessions.txt (modified) (1 diff)
- django/branches/newforms-admin/docs/settings.txt (modified) (3 diffs)
- django/branches/newforms-admin/docs/shortcuts.txt (modified) (1 diff)
- django/branches/newforms-admin/docs/syndication_feeds.txt (modified) (1 diff)
- django/branches/newforms-admin/docs/templates_python.txt (modified) (6 diffs)
- django/branches/newforms-admin/docs/templates.txt (modified) (5 diffs)
- django/branches/newforms-admin/docs/tutorial02.txt (modified) (14 diffs)
- django/branches/newforms-admin/tests/modeltests/empty/models.py (modified) (1 diff)
- django/branches/newforms-admin/tests/modeltests/field_defaults/models.py (modified) (1 diff)
- django/branches/newforms-admin/tests/modeltests/get_object_or_404/models.py (modified) (1 diff)
- django/branches/newforms-admin/tests/modeltests/invalid_models/models.py (modified) (2 diffs)
- django/branches/newforms-admin/tests/modeltests/model_forms/models.py (modified) (26 diffs)
- django/branches/newforms-admin/tests/modeltests/select_related/models.py (modified) (1 diff)
- django/branches/newforms-admin/tests/modeltests/serializers/models.py (modified) (1 diff)
- django/branches/newforms-admin/tests/modeltests/test_client/models.py (modified) (1 diff)
- django/branches/newforms-admin/tests/modeltests/user_commands/models.py (modified) (1 diff)
- django/branches/newforms-admin/tests/regressiontests/cache/tests.py (modified) (1 diff)
- django/branches/newforms-admin/tests/regressiontests/forms/localflavor/za.py (copied) (copied from django/trunk/tests/regressiontests/forms/localflavor/za.py)
- django/branches/newforms-admin/tests/regressiontests/forms/tests.py (modified) (2 diffs)
- django/branches/newforms-admin/tests/regressiontests/i18n/tests.py (modified) (2 diffs)
- django/branches/newforms-admin/tests/regressiontests/middleware (copied) (copied from django/trunk/tests/regressiontests/middleware)
- django/branches/newforms-admin/tests/regressiontests/middleware/__init__.py (copied) (copied from django/trunk/tests/regressiontests/middleware/__init__.py)
- django/branches/newforms-admin/tests/regressiontests/middleware/tests.py (copied) (copied from django/trunk/tests/regressiontests/middleware/tests.py)
- django/branches/newforms-admin/tests/regressiontests/middleware/urls.py (copied) (copied from django/trunk/tests/regressiontests/middleware/urls.py)
- django/branches/newforms-admin/tests/regressiontests/string_lookup/models.py (modified) (4 diffs)
- django/branches/newforms-admin/tests/regressiontests/templates/context.py (copied) (copied from django/trunk/tests/regressiontests/templates/context.py)
- django/branches/newforms-admin/tests/regressiontests/templates/tests.py (modified) (2 diffs)
- django/branches/newforms-admin/tests/regressiontests/views/views.py (modified) (1 diff)
- django/branches/newforms-admin/tests/runtests.py (modified) (1 diff)
- django/branches/newforms-admin/tests/urls.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/newforms-admin
- Property svnmerge-integrated changed from /django/trunk:1-4345,4350-4357,4359-4365,4371-4372,4374-4377,4380-4386,4388,4390-4391,4400-4402,4404-4408,4410,4412-4419,4426-4427,4430-4432,4434,4441,4443-4444,4446-4447,4450,4452-4453,4455-4458,4476,4503,4546,4564-4569,4580-4586,4617,4630,4641-6390,6392-6782 to /django/trunk:1-4345,4350-4357,4359-4365,4371-4372,4374-4377,4380-4386,4388,4390-4391,4400-4402,4404-4408,4410,4412-4419,4426-4427,4430-4432,4434,4441,4443-4444,4446-4447,4450,4452-4453,4455-4458,4476,4503,4546,4564-4569,4580-4586,4617,4630,4641-6390,6392-6863
django/branches/newforms-admin/AUTHORS
r6777 r6864 91 91 Pete Crosier <pete.crosier@gmail.com> 92 92 Matt Croydon <http://www.postneo.com/> 93 Leah Culver <leah@pownce.com> 93 94 flavio.curella@gmail.com 94 95 Jure Cuhalev <gandalf@owca.info> … … 134 135 gandalf@owca.info 135 136 Marc Garcia <marc.garcia@accopensys.com> 137 Andy Gayton <andy-django@thecablelounge.com> 136 138 Baishampayan Ghose 137 139 Dimitris Glezos <dimitris@glezos.com> … … 174 176 Antti Kaihola <http://akaihola.blogspot.com/> 175 177 Nagy Károly <charlie@rendszergazda.com> 178 Erik Karulf <erik@karulf.com> 176 179 Ben Dean Kawamura <ben.dean.kawamura@gmail.com> 177 180 Ian G. Kelly <ian.g.kelly@gmail.com> … … 193 196 konrad@gwu.edu 194 197 knox <christobzr@gmail.com> 198 David Krauth 195 199 kurtiss@meetro.com 196 200 lakin.wecker@gmail.com … … 208 212 Philip Lindborg <philip.lindborg@gmail.com> 209 213 Simon Litchfield <simon@quo.com.au> 214 Trey Long <trey@ktrl.com> 210 215 msaelices <msaelices@gmail.com> 211 216 Matt McClanahan <http://mmcc.cx/> … … 257 262 Luke Plant <http://lukeplant.me.uk/> 258 263 plisk 264 Mihai Preda <mihai_preda@yahoo.com> 259 265 Daniel Poelzleithner <http://poelzi.org/> 260 266 polpak@yahoo.com … … 269 275 Brian Ray <http://brianray.chipy.org/> 270 276 remco@diji.biz 277 David Reynolds <david@reynoldsfamily.org.uk> 271 278 rhettg@gmail.com 272 279 ricardojbarrios@gmail.com … … 288 295 jason.sidabras@gmail.com 289 296 Jozko Skrablin <jozko.skrablin@gmail.com> 297 Ben Slavin <benjamin.slavin@gmail.com> 290 298 SmileyChris <smileychris@gmail.com> 291 299 smurf@smurf.noris.de django/branches/newforms-admin/django/conf/global_settings.py
r6777 r6864 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/newforms-admin/django/conf/__init__.py
r6613 r6864 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/newforms-admin/django/conf/locale/ca/LC_MESSAGES/djangojs.po
r5572 r6864 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/newforms-admin/django/contrib/localflavor/uk/forms.py
r5918 r6864 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/newforms-admin/django/contrib/markup/templatetags/markup.py
r6776 r6864 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/newforms-admin/django/contrib/markup/tests.py
r6776 r6864 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/newforms-admin/django/contrib/sessions/backends/base.py
r6613 r6864 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/newforms-admin/django/contrib/sessions/models.py
r6459 r6864 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/newforms-admin/django/contrib/sessions/tests.py
r6613 r6864 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/newforms-admin/django/core/cache/backends/filebased.py
r6613 r6864 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/newforms-admin/django/core/cache/backends/locmem.py
r6777 r6864 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/newforms-admin/django/core/cache/__init__.py
r4265 r6864 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/newforms-admin/django/core/exceptions.py
r2809 r6864 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/newforms-admin/django/core/handlers/base.py
r6761 r6864 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/newforms-admin/django/core/handlers/modpython.py
r6761 r6864 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/newforms-admin/django/core/handlers/wsgi.py
r6761 r6864 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/newforms-admin/django/core/management/commands/syncdb.py
r6342 r6864 34 34 try: 35 35 __import__(app_name + '.management', {}, {}, ['']) 36 except ImportError: 37 pass 36 except ImportError, exc: 37 if not exc.args[0].startswith('No module named management'): 38 raise 38 39 39 40 cursor = connection.cursor() django/branches/newforms-admin/django/core/management/__init__.py
r6777 r6864 85 85 from django.conf import settings 86 86 apps = settings.INSTALLED_APPS 87 except (AttributeError, EnvironmentError):87 except (AttributeError, ImportError): 88 88 apps = [] 89 89 … … 100 100 from django.conf import settings 101 101 project_directory = setup_environ(__import__(settings.SETTINGS_MODULE)) 102 except (AttributeError, EnvironmentError,ImportError):102 except (AttributeError, ImportError): 103 103 project_directory = None 104 104 … … 255 255 # "myproject", this code would add "/path/to/myproject" to sys.path. 256 256 project_directory, settings_filename = os.path.split(settings_mod.__file__) 257 if not project_directory: 258 project_directory = os.getcwd() 257 259 project_name = os.path.basename(project_directory) 258 260 settings_name = os.path.splitext(settings_filename)[0] django/branches/newforms-admin/django/core/management/validation.py
r6613 r6864 71 71 # existing fields, m2m fields, m2m related objects or related objects 72 72 if f.rel: 73 if f.rel.to not in models.get_models(): 74 e.add(opts, "'%s' has relation with model %s, which has not been installed" % (f.name, f.rel.to)) 75 # it is a string and we could not find the model it refers to 76 # so skip the next section 77 if isinstance(f.rel.to, (str, unicode)): 78 continue 79 73 80 rel_opts = f.rel.to._meta 74 if f.rel.to not in models.get_models():75  
