Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

i18n: merged r815:r843 from trunk

git-svn-id: http://code.djangoproject.com/svn/django/branches/i18n@844 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit d442731eb2af671d93550426cf061713a50468d2 1 parent d79cfec
authored October 11, 2005
3  django/conf/admin_media/css/global.css
@@ -230,6 +230,7 @@ fieldset.collapsed h2, fieldset.collapsed { display:block !important; }
230 230
 fieldset.collapsed .collapse-toggle { display: inline !important; }
231 231
 fieldset.collapse h2 a.collapse-toggle { color:#ffc; }
232 232
 fieldset.collapse h2 a.collapse-toggle:hover { text-decoration:underline; }
  233
+.hidden { display:none; }
233 234
 
234 235
 /* MESSAGES & ERRORS  */
235 236
 
@@ -348,7 +349,7 @@ p.file-upload { line-height:20px; margin:0; padding:0; color:#666; font-size:11p
348 349
 ul.timelist, .timelist li { list-style-type:none; margin:0; padding:0; }
349 350
 .timelist a { padding:2px; }
350 351
 
351  
-/*  OLD ORDERING WIDGET  */
  352
+/*  ORDERING WIDGET  */
352 353
 
353 354
 ul#orderthese { padding:0; margin:0; list-style-type:none; }
354 355
 ul#orderthese li { list-style-type:none; display:block; padding:0; margin:6px 0; width:214px; background:#f6f6f6; white-space:nowrap; overflow:hidden; }
71  django/core/cache.py
@@ -15,7 +15,7 @@
15 15
     memcached://127.0.0.1:11211/    A memcached backend; the server is running
16 16
                                     on localhost port 11211.
17 17
 
18  
-    db://tablename/                 A database backend in a table named 
  18
+    db://tablename/                 A database backend in a table named
19 19
                                     "tablename". This table should be created
20 20
                                     with "django-admin createcachetable".
21 21
 
@@ -26,7 +26,7 @@
26 26
                                     probably don't want to use this except for
27 27
                                     testing. Note that this cache backend is
28 28
                                     NOT threadsafe!
29  
-                                        
  29
+
30 30
     locmem:///                      A more sophisticaed local memory cache;
31 31
                                     this is multi-process- and thread-safe.
32 32
 
@@ -72,7 +72,6 @@ class InvalidCacheBackendError(Exception):
72 72
 ################################
73 73
 
74 74
 class _Cache:
75  
-
76 75
     def __init__(self, params):
77 76
         timeout = params.get('timeout', 300)
78 77
         try:
@@ -132,8 +131,7 @@ def has_key(self, key):
132 131
     _MemcachedCache = None
133 132
 else:
134 133
     class _MemcachedCache(_Cache):
135  
-        """Memcached cache backend."""
136  
-
  134
+        "Memcached cache backend."
137 135
         def __init__(self, server, params):
138 136
             _Cache.__init__(self, params)
139 137
             self._cache = memcache.Client([server])
@@ -161,8 +159,7 @@ def get_many(self, keys):
161 159
 import time
162 160
 
163 161
 class _SimpleCache(_Cache):
164  
-    """Simple single-process in-memory cache"""
165  
-
  162
+    "Simple single-process in-memory cache."
166 163
     def __init__(self, host, params):
167 164
         _Cache.__init__(self, params)
168 165
         self._cache = {}
@@ -230,11 +227,11 @@ def _cull(self):
230 227
     import cPickle as pickle
231 228
 except ImportError:
232 229
     import pickle
  230
+import copy
233 231
 from django.utils.synch import RWLock
234 232
 
235 233
 class _LocMemCache(_SimpleCache):
236  
-    """Thread-safe in-memory cache"""
237  
-    
  234
+    "Thread-safe in-memory cache."
238 235
     def __init__(self, host, params):
239 236
         _SimpleCache.__init__(self, host, params)
240 237
         self._lock = RWLock()
@@ -250,7 +247,7 @@ def get(self, key, default=None):
250 247
             elif exp < now:
251 248
                 should_delete = True
252 249
             else:
253  
-                return self._cache[key]
  250
+                return copy.deepcopy(self._cache[key])
254 251
         finally:
255 252
             self._lock.reader_leaves()
256 253
         if should_delete:
@@ -261,14 +258,14 @@ def get(self, key, default=None):
261 258
                 return default
262 259
             finally:
263 260
                 self._lock.writer_leaves()
264  
-                
  261
+
265 262
     def set(self, key, value, timeout=None):
266 263
         self._lock.writer_enters()
267 264
         try:
268 265
             _SimpleCache.set(self, key, value, timeout)
269 266
         finally:
270 267
             self._lock.writer_leaves()
271  
-            
  268
+
272 269
     def delete(self, key):
273 270
         self._lock.writer_enters()
274 271
         try:
@@ -284,8 +281,7 @@ def delete(self, key):
284 281
 import urllib
285 282
 
286 283
 class _FileCache(_SimpleCache):
287  
-    """File-based cache"""
288  
-    
  284
+    "File-based cache."
289 285
     def __init__(self, dir, params):
290 286
         self._dir = dir
291 287
         if not os.path.exists(self._dir):
@@ -293,7 +289,7 @@ def __init__(self, dir, params):
293 289
         _SimpleCache.__init__(self, dir, params)
294 290
         del self._cache
295 291
         del self._expire_info
296  
-        
  292
+
297 293
     def get(self, key, default=None):
298 294
         fname = self._key_to_file(key)
299 295
         try:
@@ -308,7 +304,7 @@ def get(self, key, default=None):
308 304
         except (IOError, pickle.PickleError):
309 305
             pass
310 306
         return default
311  
-        
  307
+
312 308
     def set(self, key, value, timeout=None):
313 309
         fname = self._key_to_file(key)
314 310
         if timeout is None:
@@ -327,16 +323,16 @@ def set(self, key, value, timeout=None):
327 323
             pickle.dump(value, f, 2)
328 324
         except (IOError, OSError):
329 325
             raise
330  
-            
  326
+
331 327
     def delete(self, key):
332 328
         try:
333 329
             os.remove(self._key_to_file(key))
334 330
         except (IOError, OSError):
335 331
             pass
336  
-            
  332
+
337 333
     def has_key(self, key):
338 334
         return os.path.exists(self._key_to_file(key))
339  
-        
  335
+
340 336
     def _cull(self, filelist):
341 337
         if self.cull_frequency == 0:
342 338
             doomed = filelist
@@ -348,7 +344,7 @@ def _cull(self, filelist):
348 344
             except (IOError, OSError):
349 345
                 pass
350 346
 
351  
-    def _createdir(self):    
  347
+    def _createdir(self):
352 348
         try:
353 349
             os.makedirs(self._dir)
354 350
         except OSError:
@@ -366,22 +362,21 @@ def _key_to_file(self, key):
366 362
 from datetime import datetime
367 363
 
368 364
 class _DBCache(_Cache):
369  
-    """SQL cache backend"""
370  
-    
  365
+    "SQL cache backend."
371 366
     def __init__(self, table, params):
372 367
         _Cache.__init__(self, params)
373 368
         self._table = table
374  
-        max_entries = params.get('max_entries', 300) 
375  
-        try: 
376  
-            self._max_entries = int(max_entries) 
377  
-        except (ValueError, TypeError): 
378  
-            self._max_entries = 300 
379  
-        cull_frequency = params.get('cull_frequency', 3) 
380  
-        try: 
381  
-            self._cull_frequency = int(cull_frequency) 
382  
-        except (ValueError, TypeError): 
383  
-            self._cull_frequency = 3 
384  
-        
  369
+        max_entries = params.get('max_entries', 300)
  370
+        try:
  371
+            self._max_entries = int(max_entries)
  372
+        except (ValueError, TypeError):
  373
+            self._max_entries = 300
  374
+        cull_frequency = params.get('cull_frequency', 3)
  375
+        try:
  376
+            self._cull_frequency = int(cull_frequency)
  377
+        except (ValueError, TypeError):
  378
+            self._cull_frequency = 3
  379
+
385 380
     def get(self, key, default=None):
386 381
         cursor = db.cursor()
387 382
         cursor.execute("SELECT cache_key, value, expires FROM %s WHERE cache_key = %%s" % self._table, [key])
@@ -394,7 +389,7 @@ def get(self, key, default=None):
394 389
             db.commit()
395 390
             return default
396 391
         return pickle.loads(base64.decodestring(row[1]))
397  
-        
  392
+
398 393
     def set(self, key, value, timeout=None):
399 394
         if timeout is None:
400 395
             timeout = self.default_timeout
@@ -417,17 +412,17 @@ def set(self, key, value, timeout=None):
417 412
             pass
418 413
         else:
419 414
             db.commit()
420  
-        
  415
+
421 416
     def delete(self, key):
422 417
         cursor = db.cursor()
423 418
         cursor.execute("DELETE FROM %s WHERE cache_key = %%s" % self._table, [key])
424 419
         db.commit()
425  
-        
  420
+
426 421
     def has_key(self, key):
427 422
         cursor = db.cursor()
428 423
         cursor.execute("SELECT cache_key FROM %s WHERE cache_key = %%s" % self._table, [key])
429 424
         return cursor.fetchone() is not None
430  
-        
  425
+
431 426
     def _cull(self, cursor, now):
432 427
         if self._cull_frequency == 0:
433 428
             cursor.execute("DELETE FROM %s" % self._table)
@@ -438,7 +433,7 @@ def _cull(self, cursor, now):
438 433
             if num > self._max_entries:
439 434
                 cursor.execute("SELECT cache_key FROM %s ORDER BY cache_key LIMIT 1 OFFSET %%s" % self._table, [num / self._cull_frequency])
440 435
                 cursor.execute("DELETE FROM %s WHERE cache_key < %%s" % self._table, [cursor.fetchone()[0]])
441  
-        
  436
+
442 437
 ##########################################
443 438
 # Read settings and load a cache backend #
444 439
 ##########################################
4  django/core/management.py
@@ -144,6 +144,10 @@ def get_sql_delete(mod):
144 144
         for row in cursor.fetchall():
145 145
             output.append("DELETE FROM auth_admin_log WHERE content_type_id = %s;" % row[0])
146 146
 
  147
+    # Close database connection explicitly, in case this output is being piped
  148
+    # directly into a database client, to avoid locking issues.
  149
+    db.db.close()
  150
+
147 151
     return output[::-1] # Reverse it, to deal with table dependencies.
148 152
 get_sql_delete.help_doc = "Prints the DROP TABLE SQL statements for the given model module name(s)."
149 153
 get_sql_delete.args = APP_ARGS
3  django/middleware/cache.py
... ...
@@ -1,4 +1,3 @@
1  
-import copy
2 1
 from django.conf import settings
3 2
 from django.core.cache import cache
4 3
 from django.utils.cache import get_cache_key, learn_cache_key, patch_response_headers
@@ -49,7 +48,7 @@ def process_request(self, request):
49 48
             return None # No cache information available, need to rebuild.
50 49
 
51 50
         request._cache_update_cache = False
52  
-        return copy.copy(response)
  51
+        return response
53 52
 
54 53
     def process_response(self, request, response):
55 54
         "Sets the cache, if needed."
4  django/utils/decorators.py
@@ -12,6 +12,10 @@ def _wrapped_view(request, *args, **kwargs):
12 12
                 result = middleware.process_request(request)
13 13
                 if result is not None:
14 14
                     return result
  15
+            if hasattr(middleware, 'process_view'):
  16
+                result = middleware.process_view(request, view_func, **kwargs)
  17
+                if result is not None:
  18
+                    return result
15 19
             response = view_func(request, *args, **kwargs)
16 20
             if hasattr(middleware, 'process_response'):
17 21
                 result = middleware.process_response(request, response)
3  django/views/generic/list_detail.py
@@ -32,6 +32,8 @@ def object_list(request, app_label, module_name, paginate_by=None, allow_empty=F
32 32
             the previous page
33 33
         pages
34 34
             number of pages, total
  35
+        hits
  36
+            number of objects, total
35 37
     """
36 38
     mod = models.get_module(app_label, module_name)
37 39
     lookup_kwargs = extra_lookup_kwargs.copy()
@@ -56,6 +58,7 @@ def object_list(request, app_label, module_name, paginate_by=None, allow_empty=F
56 58
             'next': page + 1,
57 59
             'previous': page - 1,
58 60
             'pages': paginator.pages,
  61
+            'hits' : paginator.hits,
59 62
         })
60 63
     else:
61 64
         object_list = mod.get_list(**lookup_kwargs)
5  docs/db-api.txt
@@ -449,8 +449,7 @@ Related objects (e.g. ``Choices``) are created using convenience functions::
449 449
     >>> p.get_choice_count()
450 450
     4
451 451
 
452  
-Each of those ``add_choice`` methods is equivalent to (except obviously much
453  
-simpler than)::
  452
+Each of those ``add_choice`` methods is equivalent to (but much simpler than)::
454 453
 
455 454
     >>> c = polls.Choice(poll_id=p.id, choice="Over easy", votes=0)
456 455
     >>> c.save()
@@ -459,6 +458,8 @@ Note that when using the `add_foo()`` methods, you do not give any value
459 458
 for the ``id`` field, nor do you give a value for the field that stores
460 459
 the relation (``poll_id`` in this case).
461 460
 
  461
+The ``add_FOO()`` method always returns the newly created object.
  462
+
462 463
 Deleting objects
463 464
 ================
464 465
 
12  docs/generic_views.txt
@@ -115,7 +115,7 @@ The date-based generic functions are:
115 115
     Yearly archive. Requires that the ``year`` argument be present in the URL
116 116
     pattern.
117 117
 
118  
-    Uses the template ``app_label/module_name__archive_year`` by default.
  118
+    Uses the template ``app_label/module_name_archive_year`` by default.
119 119
 
120 120
     Has the following template context:
121 121
 
@@ -134,7 +134,7 @@ The date-based generic functions are:
134 134
     default, which is a three-letter month abbreviation. To change it to use
135 135
     numbers, use ``"%m"``.
136 136
 
137  
-    Uses the template ``app_label/module_name__archive_month`` by default.
  137
+    Uses the template ``app_label/module_name_archive_month`` by default.
138 138
 
139 139
     Has the following template context:
140 140
 
@@ -151,7 +151,7 @@ The date-based generic functions are:
151 151
     also pass ``day_format``, which defaults to ``"%d"`` (day of the month as a
152 152
     decimal number, 1-31).
153 153
 
154  
-    Uses the template ``app_label/module_name__archive_day`` by default.
  154
+    Uses the template ``app_label/module_name_archive_day`` by default.
155 155
 
156 156
     Has the following template context:
157 157
 
@@ -246,6 +246,8 @@ Individual views are:
246 246
             The previous page
247 247
         ``pages``
248 248
             Number of pages total
  249
+        ``hits``
  250
+            Total number of objects
249 251
 
250 252
 ``object_detail``
251 253
     Object detail page. This works like and takes the same arguments as
@@ -272,7 +274,7 @@ The create/update/delete views are:
272 274
     be interpolated against the object's field attributes. For example, you
273 275
     could use ``post_save_redirect="/polls/%(slug)s/"``.
274 276
 
275  
-    Uses the template ``app_label/module_name__form`` by default. This is the
  277
+    Uses the template ``app_label/module_name_form`` by default. This is the
276 278
     same template as the ``update_object`` view below. Your template can tell
277 279
     the different by the presence or absence of ``{{ object }}`` in the
278 280
     context.
@@ -294,7 +296,7 @@ The create/update/delete views are:
294 296
     ``list_detail.object_detail`` does (see above), and the same
295 297
     ``post_save_redirect`` as ``create_object`` does.
296 298
 
297  
-    Uses the template ``app_label/module_name__form`` by default.
  299
+    Uses the template ``app_label/module_name_form`` by default.
298 300
 
299 301
     Has the following template context:
300 302
 
22  docs/model-api.txt
@@ -95,8 +95,8 @@ The following arguments are available to all field types. All are optional.
95 95
             ('GR', 'Graduate'),
96 96
         )
97 97
 
98  
-        The first element in each tuple is the actual value to be stored. The
99  
-        second element is the human-readable name for the option.
  98
+    The first element in each tuple is the actual value to be stored. The
  99
+    second element is the human-readable name for the option.
100 100
 
101 101
 ``core``
102 102
     For objects that are edited inline to a related object.
@@ -248,18 +248,18 @@ Here are all available field types:
248 248
     uploaded files don't fill up the given directory).
249 249
 
250 250
     The admin represents this as an ``<input type="file">`` (a file-upload widget).
251  
-    
252  
-    Using a `FieldField` or an ``ImageField`` (see below) in a model takes a few 
  251
+
  252
+    Using a `FieldField` or an ``ImageField`` (see below) in a model takes a few
253 253
     steps:
254  
-    
  254
+
255 255
         1. In your settings file, you'll need to define ``MEDIA_ROOT``as the
256 256
            full path to a directory where you'd like Django to store uploaded
257 257
            files. (For performance, these files are not stored in the database.)
258 258
            Define ``MEDIA_URL`` as the base public URL of that directory. Make
259 259
            sure that this directory is writable by the Web server's user
260 260
            account.
261  
-        
262  
-        2. Add the ``FileField`` or ``ImageField`` to your model, making sure 
  261
+
  262
+        2. Add the ``FileField`` or ``ImageField`` to your model, making sure
263 263
            to define the ``upload_to`` option to tell Django to which
264 264
            subdirectory of ``MEDIA_ROOT`` it should upload files.
265 265
 
@@ -269,7 +269,7 @@ Here are all available field types:
269 269
            example, if your ``ImageField`` is called ``mug_shot``, you can get
270 270
            the absolute URL to your image in a template with ``{{
271 271
            object.get_mug_shot_url }}``.
272  
-    
  272
+
273 273
     .. _`strftime formatting`: http://docs.python.org/lib/module-time.html#l2h-1941
274 274
 
275 275
 ``FloatField``
@@ -302,7 +302,7 @@ Here are all available field types:
302 302
     width of the image each time a model instance is saved.
303 303
 
304 304
     Requires the `Python Imaging Library`_.
305  
-    
  305
+
306 306
     .. _Python Imaging Library: http://www.pythonware.com/products/pil/
307 307
 
308 308
 ``IntegerField``
@@ -721,7 +721,9 @@ Here's a list of all possible ``META`` options. No options are required. Adding
721 721
         unique_together = (("driver", "restaurant"),)
722 722
 
723 723
     This is a list of lists of fields that must be unique when considered
724  
-    together. It's used in the Django admin.
  724
+    together. It's used in the Django admin and is enforced at the database
  725
+    level (i.e., the appropriate ``UNIQUE`` statements are included in the
  726
+    ``CREATE TABLE`` statement).
725 727
 
726 728
 ``verbose_name``
727 729
     A human-readable name for the object, singular::

0 notes on commit d442731

Please sign in to comment.
Something went wrong with that request. Please try again.