Django

Code

Changeset 898

Show
Ignore:
Timestamp:
10/17/05 06:33:01 (3 years ago)
Author:
hugo
Message:

i18n: merged to [897] from trunk

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/i18n/django/conf/global_settings.py

    r897 r898  
    8080# documentation. 
    8181TEMPLATE_LOADERS = ( 
     82#     'django.core.template.loaders.app_directories.load_template_source', 
    8283    'django.core.template.loaders.filesystem.load_template_source', 
    8384#     'django.core.template.loaders.eggs.load_template_source', 
     
    124125# settings modules (in the format 'foo.bar.baz') for which this admin 
    125126# is an admin. 
    126 ADMIN_FOR = [] 
     127ADMIN_FOR = () 
    127128 
    128129# Whether to check the flat-pages table as a last resort for all 404 errors. 
  • django/branches/i18n/django/conf/project_template/settings/main.py

    r897 r898  
    3131SECRET_KEY = '' 
    3232 
     33# List of callables that know how to import templates from various sources. 
     34TEMPLATE_LOADERS = ( 
     35#     'django.core.template.loaders.app_directories.load_template_source', 
     36    'django.core.template.loaders.filesystem.load_template_source', 
     37#     'django.core.template.loaders.eggs.load_template_source', 
     38) 
     39 
    3340MIDDLEWARE_CLASSES = ( 
    3441    "django.middleware.common.CommonMiddleware", 
  • django/branches/i18n/django/core/template/loaders/eggs.py

    r874 r898  
    99from django.conf.settings import INSTALLED_APPS, TEMPLATE_FILE_EXTENSION 
    1010 
    11 def load_template_source(name, dirs=None): 
     11def load_template_source(template_name, template_dirs=None): 
    1212    """ 
    1313    Loads templates from Python eggs via pkg_resource.resource_string. 
    1414 
    15     For every installed app, it tries to get the resource (app, name). 
     15    For every installed app, it tries to get the resource (app, template_name). 
    1616    """ 
    1717    if resource_string is not None: 
    18         pkg_name = 'templates/' + name + TEMPLATE_FILE_EXTENSION 
     18        pkg_name = 'templates/' + template_name + TEMPLATE_FILE_EXTENSION 
    1919        for app in INSTALLED_APPS: 
    2020            try: 
     
    2222            except: 
    2323                pass 
    24     raise TemplateDoesNotExist, name 
     24    raise TemplateDoesNotExist, template_name 
    2525load_template_source.is_usable = resource_string is not None 
  • django/branches/i18n/django/core/template/loaders/filesystem.py

    r874 r898  
    1818        error_msg = "Tried %s" % tried 
    1919    else: 
    20         error_msg = "Your TEMPLATE_DIRS settings is empty. Change it to point to at least one template directory." 
     20        error_msg = "Your TEMPLATE_DIRS setting is empty. Change it to point to at least one template directory." 
    2121    raise TemplateDoesNotExist, error_msg 
    2222load_template_source.is_usable = True 
  • django/branches/i18n/docs/design_philosophies.txt

    r869 r898  
    243243A view shouldn't care about which template system the developer uses -- or even 
    244244whether a template system is used at all. 
     245 
     246Designate between GET and POST 
     247------------------------------ 
     248 
     249GET and POST are distinct; developers should explicitly use one or the other. 
     250The framework should make it easy to distinguish between GET and POST data. 
  • django/branches/i18n/docs/model-api.txt

    r853 r898  
    253253    steps: 
    254254 
    255         1. In your settings file, you'll need to define ``MEDIA_ROOT``as the 
     255        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 
    257257           files. (For performance, these files are not stored in the database.) 
  • django/branches/i18n/docs/templates_python.txt

    r869 r898  
    288288".html" extension in a directory specified as a **template directory**. 
    289289 
    290 (The ".html" extension is just a required convention. It doesn't mean templates 
    291 can only contain HTML. They can contain whatever textual content you want.) 
     290If you don't like the requirement that templates have an ".html" extension, 
     291change your ``TEMPLATE_FILE_EXTENSION`` setting. It's set to ``".html"`` by 
     292default. 
     293 
     294Also, the .html extension doesn't mean templates can contain only HTML. They 
     295can contain whatever textual content you want. 
    292296 
    293297The TEMPLATE_DIRS setting 
     
    355359 
    356360    get_template("news/story_detail") 
     361 
     362Loader types 
     363~~~~~~~~~~~~ 
     364 
     365By default, Django uses a filesystem-based template loader, but Django comes 
     366with a few other template loaders. They're disabled by default, but you can 
     367activate them by editing your ``TEMPLATE_LOADERS`` setting. 
     368``TEMPLATE_LOADERS`` should be a tuple of strings, where each string represents 
     369a template loader. Here are the built-in template loaders: 
     370 
     371``django.core.template.loaders.filesystem.load_template_source`` 
     372    Loads templates from the filesystem, according to ``TEMPLATE_DIRS``. 
     373 
     374``django.core.template.loaders.app_directories.load_template_source`` 
     375    Loads templates from Django apps on the filesystem. For each app in 
     376    ``INSTALLED_APPS``, the loader looks for a ``templates`` subdirectory. If 
     377    the directory exists, Django looks for templates in there. 
     378 
     379    This means you can store templates with your individual apps. This also 
     380    makes it easy to distribute Django apps with default templates. 
     381 
     382    For example, for this setting:: 
     383 
     384        INSTALLED_APPS = ('myproject.polls', 'myproject.music') 
     385 
     386    ...then ``get_template("foo")`` will look for templates in these 
     387    directories, in this order: 
     388 
     389        * ``/path/to/myproject/polls/templates/foo.html`` 
     390        * ``/path/to/myproject/music/templates/music.html`` 
     391 
     392    Note that the loader performs an optimization when it is first imported: 
     393    It caches a list of which ``INSTALLED_APPS`` packages have a ``templates`` 
     394    subdirectory. 
     395 
     396``django.core.template.loaders.eggs.load_template_source`` 
     397    Just like ``app_directories`` above, but it loads templates from Python 
     398    eggs rather than from the filesystem. 
     399 
     400Django uses the template loaders in order according to the ``TEMPLATE_LOADERS`` 
     401setting. It uses each loader until a loader finds a match. 
    357402 
    358403Extending the template system