Changeset 844
- Timestamp:
- 10/11/05 15:24:45 (3 years ago)
- Files:
-
- django/branches/i18n/django/conf/admin_media/css/global.css (modified) (2 diffs)
- django/branches/i18n/django/core/cache.py (modified) (19 diffs)
- django/branches/i18n/django/core/management.py (modified) (1 diff)
- django/branches/i18n/django/middleware/cache.py (modified) (2 diffs)
- django/branches/i18n/django/utils/decorators.py (modified) (1 diff)
- django/branches/i18n/django/views/generic/list_detail.py (modified) (2 diffs)
- django/branches/i18n/docs/db-api.txt (modified) (2 diffs)
- django/branches/i18n/docs/generic_views.txt (modified) (6 diffs)
- django/branches/i18n/docs/model-api.txt (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/i18n/django/conf/admin_media/css/global.css
r537 r844 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 */ … … 349 350 .timelist a { padding:2px; } 350 351 351 /* O LD ORDERING WIDGET */352 /* ORDERING WIDGET */ 352 353 353 354 ul#orderthese { padding:0; margin:0; list-style-type:none; } django/branches/i18n/django/core/cache.py
r701 r844 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". … … 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. … … 73 73 74 74 class _Cache: 75 76 75 def __init__(self, params): 77 76 timeout = params.get('timeout', 300) … … 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) … … 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) … … 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) … … 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() … … 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() … … 269 266 finally: 270 267 self._lock.writer_leaves() 271 268 272 269 def delete(self, key): 273 270 self._lock.writer_enters() … … 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 … … 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) … … 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) … … 328 324 except (IOError, OSError): 329 325 raise 330 326 331 327 def delete(self, key): 332 328 try: … … 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: … … 349 345 pass 350 346 351 def _createdir(self): 347 def _createdir(self): 352 348 try: 353 349 os.makedirs(self._dir) … … 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() … … 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: … … 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: … … 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 # django/branches/i18n/django/core/management.py
r815 r844 144 144 for row in cursor.fetchall(): 145 145 output.append("DELETE FROM auth_admin_log WHERE content_type_id = %s;" % row[0]) 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() 146 150 147 151 return output[::-1] # Reverse it, to deal with table dependencies. django/branches/i18n/django/middleware/cache.py
r815 r844 1 import copy2 1 from django.conf import settings 3 2 from django.core.cache import cache … … 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): django/branches/i18n/django/utils/decorators.py
r815 r844 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'): django/branches/i18n/django/views/generic/list_detail.py
r775 r844 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) … … 57 59 'previous': page - 1, 58 60 'pages': paginator.pages, 61 'hits' : paginator.hits, 59 62 }) 60 63 else: django/branches/i18n/docs/db-api.txt
r787 r844 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) … … 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). 460 461 The ``add_FOO()`` method always returns the newly created object. 461 462 462 463 Deleting objects django/branches/i18n/docs/generic_views.txt
r528 r844 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: … … 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: … … 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: … … 247 247 ``pages`` 248 248 Number of pages total 249 ``hits`` 250 Total number of objects 249 251 250 252 ``object_detail`` … … 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 the277 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 … … 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: django/branches/i18n/docs/model-api.txt
r775 r844 96 96 ) 97 97 98 The first element in each tuple is the actual value to be stored. The99 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`` … … 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 … … 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. … … 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 … … 303 303 304 304 Requires the `Python Imaging Library`_. 305 305 306 306 .. _Python Imaging Library: http://www.pythonware.com/products/pil/ 307 307 … … 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``
