Changeset 2388
- Timestamp:
- 02/24/06 23:53:55 (3 years ago)
- Files:
-
- django/branches/magic-removal/django/contrib/admin/templates/admin_doc/bookmarklets.html (modified) (1 diff)
- django/branches/magic-removal/django/core/cache (copied) (copied from django/trunk/django/core/cache)
- django/branches/magic-removal/django/core/cache/backends (copied) (copied from django/trunk/django/core/cache/backends)
- django/branches/magic-removal/django/core/cache/backends/base.py (copied) (copied from django/trunk/django/core/cache/backends/base.py)
- django/branches/magic-removal/django/core/cache/backends/db.py (copied) (copied from django/trunk/django/core/cache/backends/db.py) (5 diffs)
- django/branches/magic-removal/django/core/cache/backends/dummy.py (copied) (copied from django/trunk/django/core/cache/backends/dummy.py)
- django/branches/magic-removal/django/core/cache/backends/filebased.py (copied) (copied from django/trunk/django/core/cache/backends/filebased.py)
- django/branches/magic-removal/django/core/cache/backends/__init__.py (copied) (copied from django/trunk/django/core/cache/backends/__init__.py)
- django/branches/magic-removal/django/core/cache/backends/locmem.py (copied) (copied from django/trunk/django/core/cache/backends/locmem.py)
- django/branches/magic-removal/django/core/cache/backends/memcached.py (copied) (copied from django/trunk/django/core/cache/backends/memcached.py)
- django/branches/magic-removal/django/core/cache/backends/simple.py (copied) (copied from django/trunk/django/core/cache/backends/simple.py)
- django/branches/magic-removal/django/core/cache/__init__.py (copied) (copied from django/trunk/django/core/cache/__init__.py)
- django/branches/magic-removal/django/core/cache.py (deleted)
- django/branches/magic-removal/django/utils/timesince.py (modified) (2 diffs)
- django/branches/magic-removal/docs/cache.txt (modified) (2 diffs)
- django/branches/magic-removal/tests/othertests/defaultfilters.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/magic-removal/django/contrib/admin/templates/admin_doc/bookmarklets.html
r1522 r2388 17 17 18 18 <div id="content-main"> 19 <h3><a href="javascript:(function(){if(typeof ActiveXObject!='undefined'){x=new ActiveXObject('Microsoft.XMLHTTP')}else if(typeof XMLHttpRequest!='undefined'){x=new XMLHttpRequest()}else{return;}x.open('HEAD',location.href,false);x.send(null);try{view=x.getResponseHeader('x-view');}catch(e){alert('No view found for this page');return;}if(view== "undefined"){alert("No view found for this page");}document.location='{{ admin_url }}doc/views/'+view+'/';})()">{% trans "Documentation for this page" %}</a></h3>19 <h3><a href="javascript:(function(){if(typeof ActiveXObject!='undefined'){x=new ActiveXObject('Microsoft.XMLHTTP')}else if(typeof XMLHttpRequest!='undefined'){x=new XMLHttpRequest()}else{return;}x.open('HEAD',location.href,false);x.send(null);try{view=x.getResponseHeader('x-view');}catch(e){alert('No view found for this page');return;}if(view=='undefined'){alert('No view found for this page');}document.location='{{ admin_url }}doc/views/'+view+'/';})()">{% trans "Documentation for this page" %}</a></h3> 20 20 <p>{% trans "Jumps you from any page to the documentation for the view that generates that page." %}</p> 21 21 django/branches/magic-removal/django/core/cache/backends/db.py
r2378 r2388 2 2 3 3 from django.core.cache.backends.base import BaseCache 4 from django. core.db import db, DatabaseError4 from django.db import connection 5 5 import base64, time 6 6 from datetime import datetime … … 26 26 27 27 def get(self, key, default=None): 28 cursor = db.cursor()28 cursor = connection.cursor() 29 29 cursor.execute("SELECT cache_key, value, expires FROM %s WHERE cache_key = %%s" % self._table, [key]) 30 30 row = cursor.fetchone() … … 34 34 if row[2] < now: 35 35 cursor.execute("DELETE FROM %s WHERE cache_key = %%s" % self._table, [key]) 36 db.commit()36 connection.commit() 37 37 return default 38 38 return pickle.loads(base64.decodestring(row[1])) … … 41 41 if timeout is None: 42 42 timeout = self.default_timeout 43 cursor = db.cursor()43 cursor = connection.cursor() 44 44 cursor.execute("SELECT COUNT(*) FROM %s" % self._table) 45 45 num = cursor.fetchone()[0] … … 59 59 pass 60 60 else: 61 db.commit()61 connection.commit() 62 62 63 63 def delete(self, key): 64 cursor = db.cursor()64 cursor = connection.cursor() 65 65 cursor.execute("DELETE FROM %s WHERE cache_key = %%s" % self._table, [key]) 66 db.commit()66 connection.commit() 67 67 68 68 def has_key(self, key): 69 cursor = db.cursor()69 cursor = connection.cursor() 70 70 cursor.execute("SELECT cache_key FROM %s WHERE cache_key = %%s" % self._table, [key]) 71 71 return cursor.fetchone() is not None django/branches/magic-removal/django/utils/timesince.py
r1862 r2388 17 17 (60, lambda n: ngettext('minute', 'minutes', n)) 18 18 ) 19 # Convert datetime.date to datetime.datetime for comparison 20 if d.__class__ is not datetime.datetime: 21 d = datetime.datetime(d.year, d.month, d.day) 19 22 if now: 20 23 t = now.timetuple() … … 26 29 tz = None 27 30 now = datetime.datetime(t[0], t[1], t[2], t[3], t[4], t[5], tzinfo=tz) 28 31 29 32 # ignore microsecond part of 'd' since we removed it from 'now' 30 33 delta = now - (d - datetime.timedelta(0, 0, d.microsecond)) django/branches/magic-removal/docs/cache.txt
r2339 r2388 34 34 them with semicolons. 35 35 36 This backend requires the 37 `Python memcached bindings`_. 38 36 39 db://tablename/ A database backend in a table named 37 40 "tablename". This table should be created … … 83 86 84 87 .. _memcached: http://www.danga.com/memcached/ 88 .. _Python memcached bindings: ftp://ftp.tummy.com/pub/python-memcached/ 85 89 86 90 The per-site cache django/branches/magic-removal/tests/othertests/defaultfilters.py
r1947 r2388 238 238 '1 day' 239 239 240 # datetime.date compataibility with timesince 241 >>> timesince(datetime.date.today() - datetime.timedelta(1)) 242 '1 day, 23 hours' 243 240 244 >>> default("val", "default") 241 245 'val'
