TurboGears Scaffolding - TurboGears

What is TurboGears Scaffolding?

Gearbox toolkit incorporates scaffold command, which could be very useful to quickly create new components of TurboGears software. A software generated by quickstart command of gearbox has a skeleton template in the model folder (model.py.template), a templates folder (template.html.template) and a controllers folder (controller.py.template). those ‘.template’ files are used as the basis for creating new scaffolds for a software

for example, in order to create a new version named Mymodel, simply run the subsequent command –

This command will generate model/mymodel.py with newmodel class defined in it.

The users can now make modifications in the table structure as per their requirement and then import it inside model/__init__.py to make the version available within the software.

in order to create a model, a controller class to handle it and an index page all these three components may be created simultaneously by way of the following command.

This command will result in controllersmymodel.py in which the MymodelController class is duly defined.

To start using this controller, mount it inside your application RootController just to define an instance of MymodelController. Add these lines in the controllers oot.py −

A template scaffold templatesmymodel.html will also be created in the templates folder. It will act as an index page for ‘/mymodel’ URL.

The generated mymodel.html file in the templates folder will be as follows –

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

TurboGears Topics