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

5.6. VIEWING THE APPLICATION

5.5.1 Reloading Code

During development, it’s often useful to run pserve using its --reload option. When --reload is passed to pserve, changes to any Python module your project uses will cause the server to restart. This typically makes development easier, as changes to Python code made within a Pyramid application is not put into effect until the server restarts.

For example, on UNIX:

$ ../bin/pserve development.ini --reload Starting subprocess with file monitor Starting server in PID 16601.

serving on http://0.0.0.0:6543

Now if you make a change to any of your project’s .py files or .ini files, you’ll see the server restart automatically:

development.ini changed; reloading...

-------------------- Restarting --------------------

Starting server in PID 16602. serving on http://0.0.0.0:6543

Changes to template files (such as .pt or .mak files) won’t cause the server to restart. Changes to template files don’t require a server restart as long as the pyramid.reload_templates setting in the development.ini file is true. Changes made to template files when this setting is true will take effect immediately without a server restart.

5.6 Viewing the Application

Once your application is running via pserve, you may visit http://localhost:6543/ in your browser. You will see something in your browser like what is displayed in the following image:

43

5. CREATING A PYRAMID PROJECT

This is the page shown by default when you visit an unmodified pcreate generated starter application in a browser.

5.6.1 The Debug Toolbar

If you click on the image shown at the right hand top of the page (“^DT”), you’ll be presented with a debug toolbar that provides various niceties while you’re developing. This image will float above every HTML page served by Pyramid while you develop an application, and allows you show the toolbar as necessary. Click on Hide to hide the toolbar and show the image again.

44

5.6. VIEWING THE APPLICATION

If you don’t see the debug toolbar image on the right hand top of the page, it means you’re browsing from a system that does not have debugging access. By default, for security reasons, only a browser originating from localhost (127.0.0.1) can see the debug toolbar. To allow your browser on a remote system to access the server, add the a line within the [app:main] section of the development.ini file in the form debugtoolbar.hosts = X.X.X.X. For example, if your Pyramid application is running on a remote system, and you’re browsing from a host with the IP address 192.168.1.1, you’d add something like this to enable the toolbar when your system contacts Pyramid:

[app:main]

# .. other settings ...

debugtoolbar.hosts = 192.168.1.1

For more information about what the debug toolbar allows you to do, see the documentation for pyramid_debugtoolbar.

45

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