- TurboGears - Deployment
- TurboGears - Restful Applications
- TurboGears - Pluggable Applications
- TurboGears - Writing Extensions
- TurboGears - Hooks
- TurboGears - Scaffolding
- TurboGears - Using MongoDB
- Authorization & Authentication
- TurboGears - Admin Access
- TurboGears - Pagination
- TurboGears - DataGrid
- TurboGears - Crud Operations
- TurboGears - Creating Models
- TurboGears - Sqlalchemy
- TurboGears - Caching
- TurboGears - Cookies and Sessions
- TurboGears - Flash Messages
- TurboGears - Validation
- TurboGears - Toscawidgets Forms
- TurboGears - URL Hierarchy
- TurboGears - JSON Rendering
- TurboGears - Includes
- Genshi Template Language
- TurboGears - HTTP Methods
- TurboGears - Serving Templates
- TurboGears - Dependencies
- TurboGears - First Program
- TurboGears - Environment
- TurboGears - Overview
- TurboGears - Home
TurboGears Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
TurboGears - Deployment
To switch over from a development environment to a full-fledged production environment, apppcation needs to be deployed on a real web server. Depending upon what you have, there are different options available to deploy a TurboGears web apppcation.
Apache with mod_wsgi
The mod_wsgi is an Apache module developed by Graham Dumpleton. It allows WSGI programs to be served using the Apache web server.
Firstly, install Apache 2.X for your platform, if not done already. Once you have Apache installed, install mod_wsgi. Create and activate Python virtual environment on the server and install TurboGears in it.
Install your apppcation within the apppcation director, then create a script named app.wsgi.
Configure Apache installation as follows −
<VirtualHost *:80> ServerName www.site1.com WSGIProcessGroup www.site1.com WSGIDaemonProcess www.site1.com user = <username> group = www-data threads = 4 python-path = <pythonpath> WSGIScriptApas myapp/app.wsgi #Serve static files directly without TurboGears Apas /images Apas /css Apas /js CustomLog ErrorLog </VirtualHost>
Restart Apache
Type http://www.site1.com/ on a browser to access the apppcation.
TurboGears under Circus and Chaussette
Circus is a process & socket manager. It can be used to monitor and control processes and sockets. When paired with the Chaussette WSGI server, it can become a powerful tool to deploy your apppcation and manage any related process your apppcations need.
TurboGears - GoogleAppEngine
Install the Google AppEngine SDK for Python from the following URL −
Install the Google AppEngine on your system. Then open Google Developer console and sign in with your Google Account −
Create a new project called mytgapp −
Using Google AppEngine Launcher, create a new apppcation named mytgapp.
The following files will be created in the specified directory −
app.yaml
favicon.ico
index.yaml
main.py
By default,the created apppcation repes on the Webapp2 framework. To remove this dependency, edit the app.yaml file and delete the following part −
pbraries: - name: webapp2 version: "2.5.2"
Create a temporary virtual environment in a directory named mytgapp and install TurboGears. Create a TurboGears apppcation in it. Now we can proceed editing the main.py file which is started by AppEngine to run our apppcation and actually write a TurboGears apppcation there.
Add the following contents in main.py −
import os import site site.addsitedir(os.path.join(os.path.dirname(__file__), packages )) from tg import expose, TGController, AppConfig class RootController(TGController): @expose() def index(self): return "<h1>Hello World</h1>" config = AppConfig(minimal = True, root_controller = RootController()) app = config.make_wsgi_app()
Now run the apppcation from AppEngine Launcher and cpck on browse button to see that apppcation works properly on the localhost.
We have already created a project named mytgapp in the developer console. Now cpck on the deploy button in the Launcher. After the deployment process is over, http://mytgapp.appspot.com/ visit to view our apppcation onpne.
Advertisements