Django

Code

Changeset 844

Show
Ignore:
Timestamp:
10/11/05 15:24:45 (3 years ago)
Author:
hugo
Message:

i18n: merged r815:r843 from trunk

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/i18n/django/conf/admin_media/css/global.css

    r537 r844  
    231231fieldset.collapse h2 a.collapse-toggle { color:#ffc; } 
    232232fieldset.collapse h2 a.collapse-toggle:hover { text-decoration:underline; } 
     233.hidden { display:none; } 
    233234 
    234235/* MESSAGES & ERRORS  */ 
     
    349350.timelist a { padding:2px; } 
    350351 
    351 /*  OLD ORDERING WIDGET  */ 
     352/*  ORDERING WIDGET  */ 
    352353 
    353354ul#orderthese { padding:0; margin:0; list-style-type:none; } 
  • django/branches/i18n/django/core/cache.py

    r701 r844  
    1616                                    on localhost port 11211. 
    1717 
    18     db://tablename/                 A database backend in a table named  
     18    db://tablename/                 A database backend in a table named 
    1919                                    "tablename". This table should be created 
    2020                                    with "django-admin createcachetable". 
     
    2727                                    testing. Note that this cache backend is 
    2828                                    NOT threadsafe! 
    29                                          
     29 
    3030    locmem:///                      A more sophisticaed local memory cache; 
    3131                                    this is multi-process- and thread-safe. 
     
    7373 
    7474class _Cache: 
    75  
    7675    def __init__(self, params): 
    7776        timeout = params.get('timeout', 300) 
     
    133132else: 
    134133    class _MemcachedCache(_Cache): 
    135         """Memcached cache backend.""" 
    136  
     134        "Memcached cache backend." 
    137135        def __init__(self, server, params): 
    138136            _Cache.__init__(self, params) 
     
    162160 
    163161class _SimpleCache(_Cache): 
    164     """Simple single-process in-memory cache""" 
    165  
     162    "Simple single-process in-memory cache." 
    166163    def __init__(self, host, params): 
    167164        _Cache.__init__(self, params) 
     
    231228except ImportError: 
    232229    import pickle 
     230import copy 
    233231from django.utils.synch import RWLock 
    234232 
    235233class _LocMemCache(_SimpleCache): 
    236     """Thread-safe in-memory cache""" 
    237      
     234    "Thread-safe in-memory cache." 
    238235    def __init__(self, host, params): 
    239236        _SimpleCache.__init__(self, host, params) 
     
    251248                should_delete = True 
    252249            else: 
    253                 return self._cache[key] 
     250                return copy.deepcopy(self._cache[key]) 
    254251        finally: 
    255252            self._lock.reader_leaves() 
     
    262259            finally: 
    263260                self._lock.writer_leaves() 
    264                  
     261 
    265262    def set(self, key, value, timeout=None): 
    266263        self._lock.writer_enters() 
     
    269266        finally: 
    270267            self._lock.writer_leaves() 
    271              
     268 
    272269    def delete(self, key): 
    273270        self._lock.writer_enters() 
     
    285282 
    286283class _FileCache(_SimpleCache): 
    287     """File-based cache""" 
    288      
     284    "File-based cache." 
    289285    def __init__(self, dir, params): 
    290286        self._dir = dir 
     
    294290        del self._cache 
    295291        del self._expire_info 
    296          
     292 
    297293    def get(self, key, default=None): 
    298294        fname = self._key_to_file(key) 
     
    309305            pass 
    310306        return default 
    311          
     307 
    312308    def set(self, key, value, timeout=None): 
    313309        fname = self._key_to_file(key) 
     
    328324        except (IOError, OSError): 
    329325            raise 
    330              
     326 
    331327    def delete(self, key): 
    332328        try: 
     
    334330        except (IOError, OSError): 
    335331            pass 
    336              
     332 
    337333    def has_key(self, key): 
    338334        return os.path.exists(self._key_to_file(key)) 
    339          
     335 
    340336    def _cull(self, filelist): 
    341337        if self.cull_frequency == 0: 
     
    349345                pass 
    350346 
    351     def _createdir(self):     
     347    def _createdir(self): 
    352348        try: 
    353349            os.makedirs(self._dir) 
     
    367363 
    368364class _DBCache(_Cache): 
    369     """SQL cache backend""" 
    370      
     365    "SQL cache backend." 
    371366    def __init__(self, table, params): 
    372367        _Cache.__init__(self, params) 
    373368        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 
    385380    def get(self, key, default=None): 
    386381        cursor = db.cursor() 
     
    395390            return default 
    396391        return pickle.loads(base64.decodestring(row[1])) 
    397          
     392 
    398393    def set(self, key, value, timeout=None): 
    399394        if timeout is None: 
     
    418413        else: 
    419414            db.commit() 
    420          
     415 
    421416    def delete(self, key): 
    422417        cursor = db.cursor() 
    423418        cursor.execute("DELETE FROM %s WHERE cache_key = %%s" % self._table, [key]) 
    424419        db.commit() 
    425          
     420 
    426421    def has_key(self, key): 
    427422        cursor = db.cursor() 
    428423        cursor.execute("SELECT cache_key FROM %s WHERE cache_key = %%s" % self._table, [key]) 
    429424        return cursor.fetchone() is not None 
    430          
     425 
    431426    def _cull(self, cursor, now): 
    432427        if self._cull_frequency == 0: 
     
    439434                cursor.execute("SELECT cache_key FROM %s ORDER BY cache_key LIMIT 1 OFFSET %%s" % self._table, [num / self._cull_frequency]) 
    440435                cursor.execute("DELETE FROM %s WHERE cache_key < %%s" % self._table, [cursor.fetchone()[0]]) 
    441          
     436 
    442437########################################## 
    443438# Read settings and load a cache backend # 
  • django/branches/i18n/django/core/management.py

    r815 r844  
    144144        for row in cursor.fetchall(): 
    145145            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() 
    146150 
    147151    return output[::-1] # Reverse it, to deal with table dependencies. 
  • django/branches/i18n/django/middleware/cache.py

    r815 r844  
    1 import copy 
    21from django.conf import settings 
    32from django.core.cache import cache 
     
    5049 
    5150        request._cache_update_cache = False 
    52         return copy.copy(response) 
     51        return response 
    5352 
    5453    def process_response(self, request, response): 
  • django/branches/i18n/django/utils/decorators.py

    r815 r844  
    1313                if result is not None: 
    1414                    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 
    1519            response = view_func(request, *args, **kwargs) 
    1620            if hasattr(middleware, 'process_response'): 
  • django/branches/i18n/django/views/generic/list_detail.py

    r775 r844  
    3333        pages 
    3434            number of pages, total 
     35        hits 
     36            number of objects, total 
    3537    """ 
    3638    mod = models.get_module(app_label, module_name) 
     
    5759            'previous': page - 1, 
    5860            'pages': paginator.pages, 
     61            'hits' : paginator.hits, 
    5962        }) 
    6063    else: 
  • django/branches/i18n/docs/db-api.txt

    r787 r844  
    450450    4 
    451451 
    452 Each of those ``add_choice`` methods is equivalent to (except obviously much 
    453 simpler than):: 
     452Each of those ``add_choice`` methods is equivalent to (but much simpler than):: 
    454453 
    455454    >>> c = polls.Choice(poll_id=p.id, choice="Over easy", votes=0) 
     
    459458for the ``id`` field, nor do you give a value for the field that stores 
    460459the relation (``poll_id`` in this case). 
     460 
     461The ``add_FOO()`` method always returns the newly created object. 
    461462 
    462463Deleting objects 
  • django/branches/i18n/docs/generic_views.txt

    r528 r844  
    116116    pattern. 
    117117 
    118     Uses the template ``app_label/module_name__archive_year`` by default. 
     118    Uses the template ``app_label/module_name_archive_year`` by default. 
    119119 
    120120    Has the following template context: 
     
    135135    numbers, use ``"%m"``. 
    136136 
    137     Uses the template ``app_label/module_name__archive_month`` by default. 
     137    Uses the template ``app_label/module_name_archive_month`` by default. 
    138138 
    139139    Has the following template context: 
     
    152152    decimal number, 1-31). 
    153153 
    154     Uses the template ``app_label/module_name__archive_day`` by default. 
     154    Uses the template ``app_label/module_name_archive_day`` by default. 
    155155 
    156156    Has the following template context: 
     
    247247        ``pages`` 
    248248            Number of pages total 
     249        ``hits`` 
     250            Total number of objects 
    249251 
    250252``object_detail`` 
     
    273275    could use ``post_save_redirect="/polls/%(slug)s/"``. 
    274276 
    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 
    276278    same template as the ``update_object`` view below. Your template can tell 
    277279    the different by the presence or absence of ``{{ object }}`` in the 
     
    295297    ``post_save_redirect`` as ``create_object`` does. 
    296298 
    297     Uses the template ``app_label/module_name__form`` by default. 
     299    Uses the template ``app_label/module_name_form`` by default. 
    298300 
    299301    Has the following template context: 
  • django/branches/i18n/docs/model-api.txt

    r775 r844  
    9696        ) 
    9797 
    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. 
    100100 
    101101``core`` 
     
    249249 
    250250    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 
    253253    steps: 
    254      
     254 
    255255        1. In your settings file, you'll need to define ``MEDIA_ROOT``as the 
    256256           full path to a directory where you'd like Django to store uploaded 
     
    259259           sure that this directory is writable by the Web server's user 
    260260           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 
    263263           to define the ``upload_to`` option to tell Django to which 
    264264           subdirectory of ``MEDIA_ROOT`` it should upload files. 
     
    270270           the absolute URL to your image in a template with ``{{ 
    271271           object.get_mug_shot_url }}``. 
    272      
     272 
    273273    .. _`strftime formatting`: http://docs.python.org/lib/module-time.html#l2h-1941 
    274274 
     
    303303 
    304304    Requires the `Python Imaging Library`_. 
    305      
     305 
    306306    .. _Python Imaging Library: http://www.pythonware.com/products/pil/ 
    307307 
     
    722722 
    723723    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). 
    725727 
    726728``verbose_name``