Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
pyramid.pdf
Скачиваний:
11
Добавлен:
24.03.2015
Размер:
3.82 Mб
Скачать

CHAPTER

THIRTEEN

STATIC ASSETS

An asset is any file contained within a Python package which is not a Python source code file. For example, each of the following is an asset:

a GIF image file contained within a Python package or contained within any subdirectory of a Python package.

a CSS file contained within a Python package or contained within any subdirectory of a Python package.

a JavaScript source file contained within a Python package or contained within any subdirectory of a Python package.

A directory within a package that does not have an __init__.py in it (if it possessed an __init__.py it would be a package).

a Chameleon or Mako template file contained within a Python package.

The use of assets is quite common in most web development projects. For example, when you create a Pyramid application using one of the available scaffolds, as described in Creating the Project, the directory representing the application contains a Python package. Within that Python package, there are directories full of files which are static assets. For example, there’s a static directory which contains

.css, .js, and .gif files. These asset files are delivered when a user visits an application URL.

13.1 Understanding Asset Specifications

Let’s imagine you’ve created a Pyramid application that uses a Chameleon ZPT template via the pyramid.renderers.render_to_response() API. For example, the application might address the asset using the asset specification myapp:templates/some_template.pt using that API within a views.py file inside a myapp package:

153

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]