Author: admin

  • Flash Messages

    TurboGears provides a very convenient messaging system for notifying information to user in a non-obtrusive way. TGFlash class in tg module provides support for flashing messages that are stored in a plain cookie. This class supports fetching flash messages on server side as well as client side through JavaScript. The render() method of TGFlash class, when used…

  • Validation

    A good Forms widget library should have an input validation feature. For example, the user should be forced to enter data in a mandatory field, or verify if an email field contains a valid email, without resorting to any other programmatic means (like JavaScript function) for validation. Early versions of ToscaWidgets Forms Library used to…

  • JSON Rendering

    The @expose() decorator by default renders html content. However, this can be set to json content type. TurboGears supports json rendering through tg.jsonify.JSONEncoder (**kwargs) class. To render json data simply pass json as content type to expose decorator.@expose(‘json’) def jsondata(self, **kwargs): return dict(hello = ‘World’) If ‘/jsondata’ URL is entered in browser, it will respond by showing − jsonp Rendering…

  • HTTP Methods

    Http Protocol is the foundation of data communication in world wide web. Different methods of data retrieval from specified URL are defined in this protocol. Following table summarizes different http methods − Sr.No. HTTP Methods & Description 1 GETSends data in unencrypted form to the server. Most common method. 2 HEADSame as GET, but without…

  • Serving Templates

    An Event though HTML content can be returned to the browser, for more advanced output, the use of template engine is always preferred. In a full stack project ‘quickstarted’ by gearbox, Genshi is enabled as the default template renderer. In a minimal application, however Genshi (or any other template engine, such as jinja) needs to…

  • Dependencies

    A TurboGears project contains the following directories − How to Install a project This project now needs to be installed. A setup.py is already provided in project’s base directory. Project dependencies get installed when this script is executed.Python setup.py develop By default, following dependencies are installed at the time of project set up − After installation, start…

  • First Program

    TurboGears has a minimal mode that makes it possible to create single file applications quickly. Simple examples and services can be built quickly with minimal set of dependencies. Application class in a TG application is inherited from TGController class. Methods in this class are available for access by @expose decorator from tg module. In our first application, index() method is mapped as root…

  • Environment

    Prerequisite Python 2.6 or higher. Earlier versions of TurboGears were not compliant with Python 3.X. Latest version claims to work well on Python 3.X. However, official documentation of TurboGears is still based on Python 2.7 environment. The following command installs virtualenv −pip install virtualenv This command needs administrator privileges. Add sudo before pip on Linux/Mac OS. If you are on Windows,…

  • Overview

    What is Web Framework? Web Application Framework or simply Web Framework represents a collection of libraries and modules, which enables a web application developer to write applications, without having to bother about low level details such as protocols, thread management, etc. What is TurboGears? TurboGears is a web application framework written in Python. Originally created…

  • Database Migrations

    Package git repository Requirements Installing via Composer composer require –dev phalcon/migrations Quick start What you need for quick start: After that you can execute that migrations (run) in another environment to create same DB structure. Create configuration file¶ Generate migrations¶ Basic generationvendor/bin/phalcon-migrations generate Run migrations¶ List existing migrations Usage example Migration methods¶ Each migration is…