Web-Applications: TurboGears BCHB524 2015 Lecture 25 12/02/2015BCHB524 - 2015 - Edwards.

Slides:



Advertisements
Similar presentations
Chapter 6 Server-side Programming: Java Servlets
Advertisements

JQuery MessageBoard. Lets use jQuery and AJAX in combination with a database to update and retrieve information without refreshing the page. Here we will.
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?
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.
Introduction to MVC Adding a View Page NTPCUG Tom Perkins, Ph.D.
Introduction to Model-View-Controller (MVC) Web Programming with TurboGears Leif Oppermann,
Server-Side vs. Client-Side Scripting Languages
1 Chapter 12 Working With Access 2000 on the Internet.
The easy way to a nice looking website design By a total non-designer (Me!)
INTRO TO MAKING A WEBSITE Mark Zhang.  HTML  CSS  Javascript  PHP  MySQL  …That’s a lot of stuff!
 2004 Prentice Hall, Inc. All rights reserved. Chapter 25 – Perl and CGI (Common Gateway Interface) Outline 25.1 Introduction 25.2 Perl 25.3 String Processing.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
Web-Applications: TurboGears II BCHB Lecture 26 12/03/2014BCHB Edwards.
Microsoft Windows 2003 Server. Client/Server Environment Many client computers connect to a server.
Lecture 3 – Data Storage with XML+AJAX and MySQL+socket.io
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
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.
ITIS 1210 Introduction to Web-Based Information Systems Chapter 24 How Websites Work with Databases How Websites Work with Databases.
Relational Databases: Object Relational Mappers – SQLObject II BCHB Lecture 23 11/20/2013BCHB Edwards.
JavaScript & jQuery the missing manual Chapter 11
Server-side Scripting Powering the webs favourite services.
WaveMaker Visual AJAX Studio 4.0 Training Authentication.
Python CGI programming
Relational Databases: Basic Concepts BCHB Lecture 21 11/12/2014BCHB Edwards.
Lecture 19 Web Application Frameworks Boriana Koleva Room: C54
Lecture # 6 Forms, Widgets and Event Handling. Today Questions: From notes/reading/life? Share Personal Web Page (if not too personal) 1.Introduce: How.
JAVA SERVER PAGES. 2 SERVLETS The purpose of a servlet is to create a Web page in response to a client request Servlets are written in Java, with a little.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
10/13/2015 ©2006 Scott Miller, University of Victoria 1 Content Serving Static vs. Dynamic Content Web Servers Server Flow Control Rev. 2.0.
Chapter 6 Server-side Programming: Java Servlets
Google App Engine Using Templates Jim Eng Thanks to Chuck Severance
USING WORDPRESS TO CREATE A WEBSITE (RATHER THAN A BLOG) STEP-BY-STEP INSTRUCTIONS.
Rails & Ajax Module 5. Introduction to Rails Overview of Rails Rails is Ruby based “A development framework for Web-based applications” Rails uses the.
Web Design Part I. Click Menu Site to create a new site root.
Walkthrough example including SAS output How to create a mobile WebApp? PhUSE / 12. October 2015 / Katja Glaß BHC 4:3 Template 2010 June 2014Page 1.
IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
Relational Databases: Basic Concepts BCHB Lecture 21 By Edwards & Li Slides:
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.
 Pages within our Framework  Categories within Framework  Products within Framework  Model-View-Controller description of Page, category and products.
ASP. ASP is a powerful tool for making dynamic and interactive Web pages An ASP file can contain text, HTML tags and scripts. Scripts in an ASP file are.
Class 3Intro to Databases Class 4 Simple Example of a Database We’re going to build a simple example of a database, which will allow us to register users.
 A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer requests.
Basic ActionScript and PHP Cis 126. Getting Started set up a basic folder structure so we can keep our files organized. Mirror this structure on your.
Higher Computing Science Coding the Web: HTML, JavaScript, PHP and MySQL.
Introduction to Model-View-Controller (MVC) Web Programming with TurboGears Leif Oppermann,
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
Tomcat Setup BCIS 3680 Enterprise Programming. One-Click Tomcat Setup 2  This semester we’ll try to set up Tomcat with a PowerShell script.  Preparation.
A Presentation Presentation On JSP On JSP & Online Shopping Cart Online Shopping Cart.
National College of Science & Information Technology.
Intro to WordPress (Using XAMPP)
Relational Databases: Basic Concepts
Web-Applications: TurboGears
Web-Applications: TurboGears II
Play Framework: Introduction
Introduction to Programming the WWW I
PHP Training at GoLogica in Bangalore
BASIC PHP and MYSQL Edward S. Flores.
MVC Framework, in general.
SiteBuilder 2 Introduction.
Relational Databases: Object Relational Mappers – SQLObject II
Web-Applications: TurboGears II
Relational Databases: Basic Concepts
Relational Databases: Basic Concepts
Web-Applications: TurboGears II
Relational Databases: Object Relational Mappers – SQLObject II
Web-Applications & AJAX
Relational Databases: Object Relational Mappers – SQLObject II
Web Application Development Using PHP
Presentation transcript:

Web-Applications: TurboGears BCHB Lecture 25 12/02/2015BCHB Edwards

12/02/2015BCHB Edwards2 Web-Applications Use the web-browser as the user-interface All application specific functionality comes directly from the web-server No installation impediments for the user Fast way to provide your tools to others with little operating system or user-interface barrier Natural way to supply views into complex datasets that cannot feasibly be installed elsewhere.

12/02/2015BCHB Edwards3 Web-Servers Respond to requests: with static: files, images, etc... and dynamic: your facebook page, google search results content.

12/02/2015BCHB Edwards4 Web-servers A URL is made up of many parts. protocol (http,https) computer nameresource port # (80 if omitted)

12/02/2015BCHB Edwards5 Web-servers A URL is made up of many parts. A dynamic resource may return different results depending on its parameters Additional request parameters may not be visible in the URL Cookies, POST requests protocol (http,https) computer nameresource port # (80 if omitted) resource/request parameters

12/02/2015BCHB Edwards6 Web-server Web-servers return data in HTML format for display by the web-browser. Any program can request URL resources and store (and display) the response. Any program can handle the URL request and return data in whatever format they like. TurboGears provides a pythonic web- framework for building dynamic data-driven web-application servers.

12/02/2015BCHB Edwards7 TurboGears One of many web-stacks which simplify development of web-apps Model-View-Controller (MVC) paradigm Model stores the data/information required View decides how to format/display the results Controller takes requests and determines the data to output

12/02/2015BCHB Edwards8 TurboGears Your class virtual image has version Current TurboGears version is 1.5/2.3 TurboGears admin script is: tg-admin TurboGears has been installed as an external package in the class virtual image.

12/02/2015BCHB Edwards9 Hoya Taxa TurboGears web-application for navigating the NCBI taxonomy of organisms Simple view and navigation of the data stored in a relational database Read-only (no modification of the data) No users (no login or accounts) No fancy javascript (AJAX or otherwise)

12/02/2015BCHB Edwards10 Application creation TurboGears provides an administration script to construct an initial web-application shell In the terminal: tg-admin and then: tg-admin quickstart -o Answer the questions (what you type is in red): Enter project name: HoyaTaxa Enter package name [hoyataxa]: Do you...? [no]

12/02/2015BCHB Edwards11 Start web-app and check Check that the web-application shell is working... In the terminal: ~]$ cd HoyaTaxa ~]$ python start-hoyataxa.py Start a web-browser and access the url: Lots of stuff is printed to the terminal

12/02/2015BCHB Edwards12 Start web-app and check

12/02/2015BCHB Edwards13 Start web-app and check

12/02/2015BCHB Edwards14 Tour the primary files Lets take a tour of the HoyaTaxa folder: Controller: hoyataxa/controllers.py (Data) Model: hoyataxa/model.py View / Template: hoyataxa/templates/welcome.html hoyataxa/templates/master.html

12/02/2015BCHB Edwards15 Trace the execution path Spend some time understanding how these files interact. Things to notice: Request is translated to function call in controller Dynamic content (date and time) is passed from the controller function to the template Lots of crazy stuff in the welcome.html and master.html templates, but we can remove a lot. Edit controllers.py, welcome.html, and master.html to make an "empty" application.

12/02/2015BCHB Edwards16 Edit welcome.html In welcome.html: Delete everything between the HTML tags. Delete everything in the block Reload the web-site use the reload button in web-browser Check the result... Still have some stuff from master.html but otherwise empty. master.html is intended to provide common design elements (titles, menus) on every page

12/02/2015BCHB Edwards17 Edit welcome.html Now looks like this

12/02/2015BCHB Edwards18 Edit controllers.py In the index method in controllers.py: Delete the flash function call Reload the web-site and check the effect... Remove the time and date variable Reload the web-site and check the effect... Notice that the server program "restarts" every time you change controllers.py.

12/02/2015BCHB Edwards19 Edit controllers.py Root class declaration should look like this:

12/02/2015BCHB Edwards20 Edit master.html In master.html (reload after each change) Remove block. Remove everything in the block, except for the id="content" block. Find the footer and remove the footer image. Find the sidebar and menus and remove them. Add a new header "div" as first element inside id="content". Hoya Taxa Change the footer as you like

12/02/2015BCHB Edwards21 Edit master.html Relevant section should look like this:

12/02/2015BCHB Edwards22 Empty web-app Rather than making the changes one step at a time… Download TGEmpty.zip from course data directory to your home directory. ~]$ cd ~/HoyaTaxa/hoyataxa ~]$ unzip –o ~/TGEmpty.zip ~]$ cd.. ~]$ python start-hoyataxa.py

12/02/2015BCHB Edwards23 Empty web-app Empty web-application shell looks like:

12/02/2015BCHB Edwards24 Dynamic title In controllers.py, let's send a dynamic title to the welcome.html template.

12/02/2015BCHB Edwards25 Dynamic title In welcome.html, change "Welcome to TurboGears" to ${title}.

12/02/2015BCHB Edwards26 Dynamic Title

Edit the model.py file add the necessary imports and SQLObject classes 12/02/2015BCHB Edwards27 Set up the model... # Extra imports from sqlobject from sqlobject import ForeignKey, MultipleJoin class Taxonomy(SQLObject): taxid = IntCol(alternateID=True) scientific_name = StringCol() rank = StringCol() parent = ForeignKey("Taxonomy") names = MultipleJoin("Name") children = MultipleJoin("Taxonomy",joinColumn='parent_id') class Name(SQLObject): taxonomy = ForeignKey("Taxonomy") name = StringCol() name_class = StringCol()

12/02/2015BCHB Edwards28 Set up the model... Create the model: In the terminal: ~]$ tg-admin sql create Check that the sqlite database has been created in devdata.sqlite. Use sqlitestudio to check it No data in it! Download devdata.sqlite from course data-directory

12/02/2015BCHB Edwards29 Check the data in the model... In the terminal: ~]$ tg-admin shell >>> print Taxonomy.byTaxid(9606) >>> t = Taxonomy.byTaxid(9606) >>> print t.names

12/02/2015BCHB Edwards30 Let's add some functionality In controllers.py, let's add a new request Add necessary imports from model Add new method taxa with parameter taxid Use taxid to lookup Taxonomy object Create dynamic title string Send the title and taxa object to taxa.html template Access this page/resource as: Try it!

12/02/2015BCHB Edwards31 Let's add some functionality In controllers.py, let's add a new request

12/02/2015BCHB Edwards32 Let's add some functionality Need to create taxa.html too Save welcome.html as taxa.html Change taxa.html

12/02/2015BCHB Edwards33 Let's add some functionality Not pretty, but now we have dynamic title and dynamic content...

12/02/2015BCHB Edwards34 Lets make it pretty Place the following HTML between the body tags in taxa.html: Scientific Name ${taxa.scientific_name} NCBI Taxonomy ID ${taxa.taxid} Rank ${taxa.rank} Parent ${taxa.parent}

12/02/2015BCHB Edwards35 Let's make it pretty

12/02/2015BCHB Edwards36 Fix the parent value

12/02/2015BCHB Edwards37 Fix the parent value

12/02/2015BCHB Edwards38 And make it clickable

12/02/2015BCHB Edwards39 And make it clickable

12/02/2015BCHB Edwards40 List all the children

12/02/2015BCHB Edwards41 List all children

12/02/2015BCHB Edwards42 List all names

12/02/2015BCHB Edwards43 List all names

12/02/2015BCHB Edwards44 Remove the scientific name

12/02/2015BCHB Edwards45 Remove scientific name

12/02/2015BCHB Edwards46 Let's add the lineage

12/02/2015BCHB Edwards47 Let’s add the lineage

12/02/2015BCHB Edwards48 Let’s add the lineage

12/02/2015BCHB Edwards49 Next time We can now display a taxonomy record nicely if the user types a URL...and then navigate about its heirachy. Need to be able to search the names based on a user query. Search form, list of matching results, etc... XML output for web-services.