Web-Applications: TurboGears II

Slides:



Advertisements
Similar presentations
DREAMWEAVER Welcome to our website!
Advertisements

WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
Tutorial 8 Sharing, Integrating, and Analyzing Data
The Librarian Web Page Carol Wolf CS396X. Create new controller  To create a new controller that can manage more than just books, type ruby script/generate.
Jeopardy Objects Navigation Buttons True/False Parts of a Report Vocabulary Q $100 Q $200 Q $300 Q $400 Q $500 Q $100 Q $200 Q $300 Q $400 Q $500 Final.
MIS 425 Lecture 2 – HTML Navigation, Colors, tables and Styles Instructor: Martin Neuhard
Introduction to MVC Adding a View Page NTPCUG Tom Perkins, Ph.D.
Turners SharePoint Web Site How we did it. 2 Page Anatomy Custom Search Web Part Custom Search Web Part Data Form Web Parts Content Query Web Part HTML.
1 CA201 Word Application Creating Document for the Web Week # 9 By Tariq Ibn Aziz Dammam Community college.
Best Practices for Website Design & Web Content Management.
Access Tutorial 8 Sharing, Integrating, and Analyzing Data
Web-Applications: TurboGears II BCHB Lecture 26 12/03/2014BCHB Edwards.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
Macromedia Dreamweaver CS4 Tutorial. Example of the website1 folder & images folder inside Create a folder on your computer called website1 to hold all.
JQuery Page Slider. Our goal is to get to the functionality of the Panic Coda web site.Panic Coda web site.
Copyright © Texas Education Agency, All rights reserved. 1 Web Technologies Website Development with Dreamweaver.
4-1 INTERNET DATABASE CONNECTOR Colorado Technical University IT420 Tim Peterson.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Dynamic Action with Macromedia Dreamweaver MX Barry Sosinsky Valda Hilley.
Web Technologies Website Development Trade & Industrial Education
HTML, XHTML, and CSS Chapter 12 Creating and Using XML Documents.
Creating Effective School and PTA Websites Sam Farnsworth Utah PTA Technology Specialist
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 Exploring Microsoft Office Word 2007 Chapter 8 Word and the Internet Robert Grauer, Keith.
Website Development with Dreamweaver
LiveCycle Data Services Introduction Part 2. Part 2? This is the second in our series on LiveCycle Data Services. If you missed our first presentation,
 2004 Prentice Hall, Inc. All rights reserved. 1 Chapter 34 - Case Study: Active Server Pages and XML Outline 34.1 Introduction 34.2 Setup and Message.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Recursive Functions Creating Hierarchical Reports Date: 9/30/2008 Dan McCreary President Dan McCreary & Associates (952) M.
HTML Basics BCIS 3680 Enterprise Programming. Web Client/Server Architecture 2  Your browser (the client) requests a Web page from a remote computer.
Microsoft Access 2010 Chapter 10 Administering a Database System.
Wikispaces in Education Tutorial Fatema Kashoob Nawal ALKathiri
6 th Annual Focus Users’ Conference 6 th Annual Focus Users’ Conference Import Testing Data Presented by: Adrian Ruiz Presented by: Adrian Ruiz.
Introduction to Views Stanford Drupal Camp April 6, 2013.
Microsoft FrontPage 2003 Illustrated Complete Integrating a Database with a Web Site.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Web-Applications: TurboGears II BCHB Lecture 26 12/7/2015BCHB Edwards.
Web-Applications: TurboGears BCHB Lecture 25 12/02/2015BCHB Edwards.
 Pages within our Framework  Categories within Framework  Products within Framework  Model-View-Controller description of Page, category and products.
CSC 2720 Building Web Applications Basic Frameworks for Building Dynamic Web Sites / Web Applications.
Web Site Development - Process of planning and creating a website.
1 Preparation for site Create a folder in MyDocuments: beavercheese. Create a subfolder, images Classes, career, DW beginner Download.
Advanced HTML Tags:.
Pre-Production Meet with the client to create a project plan:
Practical Office 2007 Chapter 10
Web-Applications: TurboGears
Web-Applications: TurboGears II
Building a User Interface with Forms
Play Framework: Introduction
>> Header & Footer in CSS
Bulk update E. Camelback Road #559, Phoenix, AZ Phone: Fax:
Cookies BIS1523 – Lecture 23.
MVC Framework, in general.
Exploring Microsoft® Access® 2016 Series Editor Mary Anne Poatsy
In Class Programming BIS1523 – Lecture 11.
Add Image and Title to Individual Page
Access Tutorial 8 Sharing, Integrating, and Analyzing Data
Microsoft Office Access 2003
Video list editor BIS1523 – Lecture 24.
Microsoft Office Access 2003
Relational Databases: Object Relational Mappers – SQLObject II
Chapter 18 Finalizing a Database.
Web-Applications: TurboGears II
Relational Databases: Object Relational Mappers – SQLObject II
Web-Applications & AJAX
Relational Databases: Object Relational Mappers – SQLObject II
Grauer and Barber Series Microsoft Access Chapter Two
Mr. Justin “JET” Turner CSCI 3000 – Fall 2016 Section DA MW 4:05-5:20
Tutorial 8 Sharing, Integrating, and Analyzing Data
Presentation transcript:

Web-Applications: TurboGears II BCHB524 Lecture 26 BCHB524 - Edwards

Last time… We made the empty HoyaTaxa website and learned how to make minor changes, and send dynamic content to template. We added a “taxa” information page with: Clickable Parent link (Variable number of) clickable Children links (Variable number of) names (other than sci name) Taxonomic lineage BCHB524 - Edwards

Start web-app and check Check that the web-application is working... In the class Command-Line shell: [student@localhost ~]$ cd HoyaTaxa [student@localhost HoyaTaxa]$ start-hoyataxa.py Start a web-browser and access by urls: http://localhost:8080/ http://localhost:8080/taxa/9606 http://localhost:8080/taxa?taxid=9606 BCHB524 - Edwards

Empty landing page BCHB524 - Edwards

Taxonomy page BCHB524 - Edwards

Tour the primary files The files we modified in the HoyaTaxa folder: Controller: hoyataxa/controllers.py Change the index method Add the taxa method to lookup and return Taxonomy given taxid (Data) Model: hoyataxa/model.py SQLObject classes devdata.sqlite download (or populate) the data in the sqlite database View / Template: hoyataxa/templates/welcome.html Remove all but the dynamic title hoyataxa/templates/master.html Change header and footer, remove menus hoyataxa/templates/taxa.html Set-up the taxa page layout BCHB524 - Edwards

Empty landing page BCHB524 - Edwards

Set up search form In controllers.py, define a class for the form from turbogears import validate, validators from turbogears import widgets, error_handler class SearchFields(widgets.WidgetsList):     query = widgets.TextField(label="Search Term")     mode = widgets.SingleSelectField(label="Search Mode",                                      options=["Starts with",                                               "Ends with",                                               "Contains"],                                      default="Contains") search_form = widgets.TableForm(     fields = SearchFields(),     action = "search",     submit_text = "Search"     ) class Root(controllers.RootController):     @expose(template="hoyataxa.templates.welcome")     def index(self):         return dict(form=search_form,                     title="All your taxa are belong to us") from turbogears import validate, validators from turbogears import widgets, error_handler class SearchFields(widgets.WidgetsList): query = widgets.TextField(label="Search Term") mode = widgets.SingleSelectField(label="Search Mode", options=["Starts with", "Ends with", "Contains"], default="Contains") search_form = widgets.TableForm( fields = SearchFields(), action = "search", submit_text = "Search" ) class Root(controllers.RootController): @expose(template="hoyataxa.templates.welcome") def index(self): return dict(form=search_form, title="All your taxa are belong to us") BCHB524 - Edwards

Set up search form Place the form in welcome.html <P/> <div align="center"> ${form()} </div> BCHB524 - Edwards

Set up search form BCHB524 - Edwards

Handle the search request In controllers.py, we add the search method @expose(template="hoyataxa.templates.search") def search(self,query,mode): if mode == 'Starts with': names = Name.select(Name.q.name.startswith(query)) elif mode == 'Ends with': names = Name.select(Name.q.name.endswith(query)) elif mode == 'Contains': names = Name.select(Name.q.name.contains(query)) return dict(names=names,query=query,mode=mode) BCHB524 - Edwards

Handle the search request Save taxa.html as search.html and modify <P/> <table py:if="names.count() > 0"> <tr> <th>NCBI Taxonomy ID</th> <th>Name</th> <th>Class</th> </tr> <tr py:for="n in names"> <td><A href="${tg.url('/taxa',taxid=n.taxonomy.taxid)}">${n.taxonomy.taxid}</A></td> <td>${n.name}</td> <td>${n.name_class}</td> </table> Total matches to ${mode} ${query}: ${names.count()} <A href="${tg.url('/')}">New search</A> BCHB524 - Edwards

Handle the search request Save taxa.html as search.html and modify <P/> <table py:if="names.count() > 0"> <tr> <th>NCBI Taxonomy ID</th> <th>Name</th> <th>Class</th> </tr> <tr py:for="n in names"> <td><A href="${tg.url('/taxa',taxid=n.taxonomy.taxid)}">${n.taxonomy.taxid}</A></td> <td>${n.name}</td> <td>${n.name_class}</td> </table> Total matches to ${mode} ${query}: ${names.count()} <A href="${tg.url('/')}">New search</A> BCHB524 - Edwards

Search for name: gorilla BCHB524 - Edwards

But… There is a problem. What to do about bad input? Too short, spaces at beginning or end… TurboGears provides validators to check values in the fields to make sure they are OK Nice integration with form widgets Users get error messages so they can fix the error BCHB524 - Edwards

Validation “Schema” class SearchFieldsSchema(validators.Schema): query = validators.String(min=3,strip=True) mode = validators.OneOf(["Starts with","Ends with","Contains"]) BCHB524 - Edwards

Handle errors in search parameters BCHB524 - Edwards

Problem is communicated to user BCHB524 - Edwards

Problem is communicated to user BCHB524 - Edwards

Validators can be quite complicated query = validators.All(validators.PlainText(), validators.String(min=3,strip=True)) BCHB524 - Edwards

Problem is communicated to user BCHB524 - Edwards

Setup for use by web-services Our web-site can now be accessed programatically… …as we did with urllib.urlopen in python Access: http://localhost:8080/taxa?taxid=9606 http://localhost:8080/search?query=hum&mode=Contains However, we usually don’t want to parse HTML. Programs want to parse “easy” no-frills formats. BCHB524 - Edwards

Let’s provide XML output format We need a new output template for search: searchxml.html <?xml version="1.0"?> <result xmlns:py="http://genshi.edgewall.org/"> <item py:for="n in names"> <taxid>${n.taxonomy.taxid}</taxid> <name>${n.name}</name> <class>${n.name_class}</class> </item> <query>${query}</query> <mode>${mode}</mode> </result> BCHB524 - Edwards

XML output format Next we need to tell the search method when to use it… @expose(template="hoyataxa.templates.searchxml", as_format="xml", format='xml') BCHB524 - Edwards

XML Output Format To get XML format output, add “&tg_format=xml” to end of URL. Try it: http://localhost:8080/search?query=hum&mode=Contains http://localhost:8080/search?query=hum&mode=Contains&tg_format=xml BCHB524 - Edwards

Similarly for the taxa page <?xml version="1.0"?> <result xmlns:py="http://genshi.edgewall.org/"> <item> <scientific_name>${taxa.scientific_name}</scientific_name> <taxid>${taxa.taxid}</taxid> <rank>${taxa.rank}</rank> <name py:for="n in taxa.names" py:if="n.name_class != 'scientific name'">${n.name} (${n.name_class})</name> <lineage>${'; '.join([t.scientific_name for t in lineage])}</lineage> <parent>${taxa.parent.taxid}</parent> <child py:for="c in taxa.children">${c.taxid}</child> </item> </result> BCHB524 - Edwards

Similarly for the taxa page BCHB524 - Edwards

XML Output Format To get XML format output, add “tg_format=xml” to end of URL. Try it: http://localhost:8080/taxa?taxid=9606 http://localhost:8080/taxa?taxid=9606&tg_format=xml http://localhost:8080/taxa/9606 http://localhost:8080/taxa/9606?tg_format=xml BCHB524 - Edwards

All done… We can now display a taxonomy record nicely if the user types a URL ...and then navigate about its heirachy. Can search the names based on a user query. Search form, list of matching results, etc... XML output for web-services. BCHB524 - Edwards

TODO… If only one matching search result – jump straight to taxa page… Even if only one taxa matches? Search/lookup by taxid too? Make pages and tables prettier Center and position tables on page Alternate row colors BCHB524 - Edwards