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

5.5. RUNNING THE PROJECT APPLICATION

> ..\Scripts\python.exe setup.py test -q

Here’s sample output from a test run on UNIX:

$ ../bin/python setup.py test -q running test

running egg_info

writing requirements to MyProject.egg-info/requires.txt writing MyProject.egg-info/PKG-INFO

writing top-level names to MyProject.egg-info/top_level.txt

writing dependency_links to MyProject.egg-info/dependency_links.txt writing entry points to MyProject.egg-info/entry_points.txt

reading manifest file ’MyProject.egg-info/SOURCES.txt’ writing manifest file ’MyProject.egg-info/SOURCES.txt’ running build_ext

..

----------------------------------------------------------------------

Ran 1 test in 0.108s

OK

latex-note.png

The -q option is passed to the setup.py test command to limit the output to a stream of dots. If you don’t pass -q, you’ll see more verbose test result output (which normally isn’t very useful).

The tests themselves are found in the tests.py module in your pcreate generated project. Within a project generated by the starter scaffold, a single sample test exists.

5.5 Running The Project Application

Once a project is installed for development, you can run the application it represents using the pserve command against the generated configuration file. In our case, this file is named development.ini.

On UNIX:

41

5. CREATING A PYRAMID PROJECT

$ ../bin/pserve development.ini

On Windows:

> ..\Scripts\pserve development.ini

Here’s sample output from a run of pserve on UNIX:

$ ../bin/pserve development.ini Starting server in PID 16601.

serving on 0.0.0.0:6543 view at http://127.0.0.1:6543

By default, Pyramid applications generated from a scaffold will listen on TCP port 6543. You can shut down a server started this way by pressing Ctrl-C.

The default server used to run your Pyramid application when a project is created from a scaffold is named Waitress. This server is what prints the serving on... line when you run pserve. It’s a good idea to use this server during development, because it’s very simple. It can also be used for light production. Setting your application up under a different server is not advised until you’ve done some development work under the default server, particularly if you’re not yet experienced with Python web development. Python web server setup can be complex, and you should get some confidence that your application works in a default environment before trying to optimize it or make it “more like production”. It’s awfully easy to get sidetracked trying to set up a nondefault server for hours without actually starting to do any development. One of the nice things about Python web servers is that they’re largely interchangeable, so if your application works under the default server, it will almost certainly work under any other server in production if you eventually choose to use a different one. Don’t worry about it right now.

You can change the port on which the server runs on by changing the development.ini file. For example, you can change the port = 6543 line in the development.ini file’s [server:main] section to port = 8080 to run the server on port 8080 instead of port 6543.

For more detailed information about the startup process, see Startup. For more information about environment variables and configuration file settings that influence startup and runtime behavior, see Environment Variables and .ini File Settings.

42

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