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

CHAPTER

TWENTY

COMMAND-LINE PYRAMID

Your Pyramid application can be controlled and inspected using a variety of command-line utilities. These utilities are documented in this chapter.

20.1 Displaying Matching Views for a Given URL

For a big application with several views, it can be hard to keep the view configuration details in your head, even if you defined all the views yourself. You can use the pviews command in a terminal window to print a summary of matching routes and views for a given URL in your application. The pviews command accepts two arguments. The first argument to pviews is the path to your application’s .ini file and section name inside the .ini file which points to your application. This should be of the format config_file#section_name. The second argument is the URL to test for matching views. The section_name may be omitted; if it is, it’s considered to be main.

Here is an example for a simple view configuration using traversal:

1

2

3

4

5

6

7

8

9

10

11

$ ../bin/pviews development.ini#tutorial /FrontPage

URL = /FrontPage

context: <tutorial.models.Page object at 0xa12536c> view name:

View:

-----

tutorial.views.view_page required permission = view

211

20. COMMAND-LINE PYRAMID

The output always has the requested URL at the top and below that all the views that matched with their view configuration details. In this example only one view matches, so there is just a single View section. For each matching view, the full code path to the associated view callable is shown, along with any permissions and predicates that are part of that view configuration.

A more complex configuration might generate something like this:

1 $ ../bin/pviews development.ini#shootout /about

2

3 URL = /about

4

5 context: <shootout.models.RootFactory object at 0xa56668c>

6view name: about

7

8Route:

9------

10route name: about

11route pattern: /about

12route path: /about

13subpath:

14route predicates (request method = GET)

15

16View:

17-----

18shootout.views.about_view

19required permission = view

20view predicates (request_param testing, header X/header)

21

22Route:

23------

24route name: about_post

25route pattern: /about

26route path: /about

27subpath:

28route predicates (request method = POST)

29

30View:

31-----

32shootout.views.about_view_post

33required permission = view

34view predicates (request_param test)

35

36View:

37-----

38shootout.views.about_view_post2

39required permission = view

212

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