Download presentation
Presentation is loading. Please wait.
Published byElaine Norris Modified over 9 years ago
1
TurboGears A python-based web Megaframework
2
What does it do? Write web applications faster. Achieves this by allowing the user to write applications in a high- level interpreted programming language while conforming to the Model-View-Controller architecture.
3
What does it use? Kid Kid CherryPy CherryPy SQLObject SQLObject MochiKit MochiKit
4
Code Examples :Model: # Pretend all the import statements are here. # Next two lines are generated in every project. hub = PackageHub("newwiki") __connection__ = hub # SQL equivalent to defining a table Page with the columns # “Pagename” with a length of 30 and “data” with no max length # set. AlternateID=True ensures uniqueness with pagename. class Page(SQLObject): pagename=StringCol(alternateID=True, length=30) data=StringCol()
5
Code Examples, continued :Controller: # Pretend there are import statements here, too. wikiwords=re.compile(r"\b([A-Z]\w+[A-Z]+\w+)")#Detects words LikeThis or TurboGears. class Root(controllers.RootController): @turbogears.expose(html=".templates.page") #Tells TG to use the page template def default(self, pagename): #for root requests along with the return self.index(pagename) #variable pagename @turbogears.expose(html=".templates.edit") #The edit method uses the edit def edit(self, pagename): #template page = Page.byPagename(pagename) #Finds the pagename in the database return dict(pagename=page.pagename, data=page.data, new=False)
6
Code Examples, continued :View: <html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#" py:extends="'master.kid'"> <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/> Welcome to TurboGears Viewing You will never see this. You can return to the FrontPage.
7
Other included components TurboGears toolbox A web application that: -Includes a frontend to the SQLobject database -A visual model diagram generator -An widget browser -Shows version information to all included parts -A python web-console
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.