generates scaffolding/framework for models, views

Similar documents
widgets, events, layout loosely similar to Swing test browser, or plugin for testing with real browser on local system

Lecture 10(-ish) Web [Application] Frameworks

Google Web Toolkit (GWT)

정재성

Creating GWT Applications in Eclipse

MIT AITI Python Software Development Lab DJ1:

Front End Programming

Reminders. Full Django products are due next Thursday! CS370, Günay (Emory) Spring / 6

Developing Ajax Web Apps with GWT. Session I

CE419 Web Programming. Session 15: Django Web Framework

But before understanding the Selenium WebDriver concept, we need to know about the Selenium first.

Berner Fachhochschule Haute école spécialisée bernoise Berne University of Applied Sciences 2

Say goodbye to the pains of Ajax. Yibo

Google Web Toolkit. David Geary. code.google.com/webtoolkit. corewebdeveloper.com

JavaScript CS 4640 Programming Languages for Web Applications

JavaScript CS 4640 Programming Languages for Web Applications

Google Web Toolkit (GWT)

Server-Side Web Programming: Python (Part 2) Copyright 2017 by Robert M. Dondero, Ph.D Princeton University

Govt. of Karnataka, Department of Technical Education Diploma in Computer Science & Engineering. Fifth Semester. Subject: Web Programming

GWT: The Technical Advantage. Presenter: Anirudh Dewani Company Name: Google

Web development using PHP & MySQL with HTML5, CSS, JavaScript

LSI's VMware vcenter Plug-In: A Study in the Use of Open Source Software Erik Johannes Brian Mason LSI Corp

Tooling for Ajax-Based Development. Craig R. McClanahan Senior Staff Engineer Sun Microsystems, Inc.

Google Web Toolkit (GWT) Basics. Sang Shin Java Technology Architect & Evangelist Sun Microsystems, Inc.

Networking & The Web. HCID 520 User Interface Software & Technology

About the Tutorial. Audience. Prerequisites. Disclaimer & Copyright. Django

Web Frameworks MMIS 2 VU SS Denis Helic. March 10, KMI, TU Graz. Denis Helic (KMI, TU Graz) Web Frameworks March 10, / 18

Tomasz Szumlak WFiIS AGH 23/10/2017, Kraków

Programming the World Wide Web by Robert W. Sebesta

Web 2.0 Käyttöliittymätekniikat

Static Webpage Development

welcome to BOILERCAMP HOW TO WEB DEV

We will talk about Alt-Tab from the usability perspective. Think about: - Is it learnable? - Is it efficient? - What about errors and safety?

HTML5 - INTERVIEW QUESTIONS

Creating an Online Catalogue Search for CD Collection with AJAX, XML, and PHP Using a Relational Database Server on WAMP/LAMP Server

Varargs Training & Software Development Centre Private Limited, Module: HTML5, CSS3 & JavaScript

Ajax and Web 2.0 Related Frameworks and Toolkits. Dennis Chen Director of Product Engineering / Potix Corporation

1 Introduction. 2 Web Architecture

Networking & The Web. HCID 520 User Interface Software & Technology

Live Guide Co-browsing

Web Programming. Lecture 11. University of Toronto

Strategies for Rapid Web Prototyping. Ruby on Rails. Clemens H. Cap

mgwt Cross platform development with Java

All India Council For Research & Training

GRITS AJAX & GWT. Trey Roby. GRITS 5/14/09 Roby - 1

Building Rich Applications with Appcelerator

Index. C CakePHP framework, 232 Cascading Style Sheets (CSS)

Introduction to PHP. Handling Html Form With Php. Decisions and loop. Function. String. Array

COS 333: Advanced Programming Techniques

Etanova Enterprise Solutions

Fiz: A Component Framework for Web Applications. John Ousterhout Stanford University

CSC309: Introduction to Web Programming. Lecture 11

Jquery Ajax Json Php Mysql Data Entry Example

Writing Web Apps in C++? Eric Bidelman, Google COSCUP / GNOME.Asia - Taipei, Taiwan August 14, 2010

SAURASHTRA UNIVERSITY

Web Programming and Design. MPT Senior Cycle Tutor: Tamara Week 1

CS Final Exam Review Suggestions - Spring 2018

Upload to your web space (e.g., UCSC) Due this Thursday 4/8 in class Deliverable: Send me an with the URL Grading:

Lecture : 3. Practical : 2. Course Credit. Tutorial : 0. Total : 5. Course Learning Outcomes

Web Application Expectations

1. Setup a root folder for the website 2. Create a wireframe 3. Add content 4. Create hyperlinks between pages and to external websites

Introduction Haim Michael. All Rights Reserved.

The Platform as a Service of Google. Vincenzo Gianferrari Pini


Taming AJAX with GWT. Scott Blum. Scott Blum Taming AJAX with GWT Page 1

CS637 Midterm Review

7401ICT eservice Technology. (Some of) the actual examination questions will be more precise than these.

Standard 1 The student will author web pages using the HyperText Markup Language (HTML)

AJAX Programming Chris Seddon

DRESSSHOP RESPONSIVE PRESTASHOP THEME USER GUIDE

Rapid Development with Django and App Engine. Guido van Rossum May 28, 2008

A Business Case for Ajax with Google Web Toolkit. Bruce Johnson Google, Inc.

Lecture 18. WebSocket

Technology modeling. Ralf Lämmel Software Languages Team University of Koblenz-Landau

Ajax On Rails: Build Dynamic Web Applications With Ruby By Scott Raymond READ ONLINE

Now go to bash and type the command ls to list files. The unix command unzip <filename> unzips a file.

MVC: Model View Controller

GWT and jmaki: Expanding the GWT Universe. Carla Mott, Staff Engineer, Sun Microsystems Greg Murray, Ajax Architect, Sun Microsystems

web frameworks design comparison draft - please help me improve it focus on Model-View-Controller frameworks

City of Mobile GIS Web Mapping Applications: New Technology, New Expectations

Table of Contents. Revision History. 1. Introduction Purpose Document Conventions Intended Audience and Reading Suggestions4

MARKET RESPONSIVE PRESTASHOP THEME USER GUIDE

Google Wave Client: Powered by GWT. Adam Schuck 28 May, 2009

MIT Global Startup Labs México 2013

Web API Lab. The next two deliverables you shall write yourself.

Qiufeng Zhu Advanced User Interface Spring 2017

Application Development in JAVA. Data Types, Variable, Comments & Operators. Part I: Core Java (J2SE) Getting Started

ICOM 5016 Database Systems. Database Users. User Interfaces and Tools. Chapter 8: Application Design and Development.

eclipse rich ajax platform (rap)

Introduction and first application. Luigi De Russis. Rails 101

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)

CSE 127 Computer Security

Cloud Computing Platform as a Service

Using AJAX to Easily Integrate Rich Media Elements

Javascript, Java, Flash, Silverlight, HTML5 (animation, audio/video, ) Ajax (asynchronous Javascript and XML)

JAVASCRIPT JQUERY AJAX FILE UPLOAD STACK OVERFLOW

Tangent MicroServices Documentation

World Wide Web PROGRAMMING THE PEARSON EIGHTH EDITION. University of Colorado at Colorado Springs

Credits: Some of the slides are based on material adapted from

Jquery Manually Set Checkbox Checked Or Not

Transcription:

Django by Adrian Holovaty and Jacob Kaplan-Moss (released July 2005) a collection of Python scripts to create a new project / site generates Python scripts for settings, etc. configuration info stored as Python lists creat a new application within a project generates scaffolding/framework for models, views run a development web server for local testing Django Reinhart, 1910-1953 generate a database or build interface to an existing database provide a command-line interface to application create an administrative interface for the database...

Conventional approach to building a web site user interface, logic, database access are all mixed together import MySQLdb print "Content-Type: text/html" print print "<html><head><title>books</title></head>" print "<body>" print "<h1>books</h1>" print "<ul>" connection = MySQLdb.connect(user='me', passwd='x', db='my_db') cursor = connection.cursor() cursor.execute("select name FROM books ORDER BY pub_date DESC") for row in cursor.fetchall(): print "<li>%s</li>" % row[0] print "</ul>" print "</body></html>" connection.close()

Model-View-Controller (MVC) pattern an example of a design pattern model: the structure of the data how data is defined and accessed view: the user interface what it looks like on the screen can have multiple views for one model controller: how information is moved around processing events, gathering and processing data, generating HTML,... separate model from view from processing so that when one changes, the others need not used with varying fidelity in Django, App Engine, Ruby on Rails, XCode Interface Builder,... not always clear where to draw the lines but trying to separate concerns is good

Django web framework write client code in HTML, CSS, Javascript,... Django template language helps separate form from content write server code in Python some of this is generated for you write database access with Python library calls they are translated to SQL database commands djangobook.com URLs on web page map mechanically to Python function calls regular expressions specify classes of URLs URL received by server is matched against regular expressions if a match is found, that identifies function to be called and arguments to be provided to the function

Django automatically-generated files generate framework/skeleton of code by program three basic files: models.py: database tables, etc. views.py: business logic, formatting of output urls.py: linkage between web requests and view functions plus others for special purposes: settings.py: db type, names of modules,... tests.py: test files templates: for generating and filling HTML info

Database linkage DATABASES = {! in settings.py 'default': {! 'ENGINE': 'django.db.backends.sqlite3',! 'NAME': '/Users/bwk/dj1/mysite/sql3.db',...! from django.db import models! in models.py class Books(models.Model):! isbn = models.charfield(max_length=15)! title = models.charfield(max_length=35)! author = models.charfield(max_length=35)! price = models.floatfield()! BEGIN;! CREATE TABLE "db1_books" (! "id" integer NOT NULL PRIMARY KEY,! "isbn" varchar(15) NOT NULL,! "title" varchar(35) NOT NULL,! "author" varchar(35) NOT NULL,! "price" real NOT NULL! );! generated by Django

URL patterns regular expressions used to recognize parameters and pass them to Python functions provides linkage between web page and what functions are called for semantic actions urlpatterns = patterns('', (r'^time/$', current_datetime), ) (r'^time/plus/(\d{1,2})/$', hours_ahead), a reference to web page /time/ calls the function current_datetime() tagged regular expressions for parameters: url /time/plus/12 calls the function hours_ahead(12)

Templates for generating HTML try to separate page design from code that generates it Django has a specialized language for including HTML within code loosely analogous to PHP mechanism # latest_books.html (the template) <html><head><title>books</title></head> <body> <h1>books</h1> <ul> {% for book in book_list %} <li>{{ book.name }}</li> {% endfor %} </ul> </body></html>

Administrative interface most systems need a way to modify the database even if initially created from bulk data add / remove users, set passwords,... add / remove records fix contents of records... often requires special code Django generates an administrative interface automatically loosely equivalent to MyPhpAdmin urlpatterns = patterns('',... # Uncomment this for admin: # (r'^admin/', include('django.contrib.admin.urls')),

Google Web Toolkit (GWT) (first available May 2006) write client (browser) code in Java widgets, events, layout loosely similar to Swing test client code on server side test browser, or plugin for testing with real browser on local system compile Java to Javascript and HTML/CSS [once it works] use generated code as part of a web page generated code is browser independent (diff versions for diff browsers) can use development environments like Eclipse can use JUnit for testing strong type checking on source detect typos, etc., at compile time (unlike Javascript) doesn't handle all Java runtime libraries? no explicit support for database access on server use whatever package is available

Unphonebook in GWT

GWT example (client side, excerpt 1) public void onmoduleload() { final TextBox namefield = new TextBox(); final Label outputarea = new Label(); // was TextArea RootPanel.get("nameFieldContainer").add(nameField); RootPanel.get("outputAreaContainer").add(outputArea); namefield.setfocus(true); final Label texttoserverlabel = new Label(); final HTML serverresponselabel = new HTML(); // Create a handler for the sendbutton and namefield class MyHandler implements KeyUpHandler { public void onkeyup(keyupevent event) { if (namefield.gettext().length() > 1) { sendnametoserver(); } }

GWT example (client side, excerpt 2) private void sendnametoserver() { } } String texttoserver = namefield.gettext(); texttoserverlabel.settext(texttoserver); serverresponselabel.settext(""); greetingservice.greetserver(texttoserver, new AsyncCallback<String>() { }); public void onfailure(throwable caught) { } public void onsuccess(string result) { } outputarea.settext(result); // Add a handler to send the name to the server MyHandler handler = new MyHandler(); namefield.addkeyuphandler(handler);

GWT example (client side, excerpt 3) <h1 align="left">gwt Unphonebook</h1> <table > <tr> <td id="namefieldcontainer"></td> </tr> <tr> <td colspan="2" style="color:red;" </tr> </table> id="errorlabelcontainer"></td> <pre id="outputareacontainer" style="backgroundcolor:#ffff00; fontweight:bold;"></pre>

GWT example (server side) public class GreetingServiceImpl extends RemoteServiceServlet implements GreetingService { public String greetserver(string input) throws IllegalArgumentException { String result = ""; Runtime rt = Runtime.getRuntime(); Process p; try { input = escapehtml(input); p = rt.exec("grep -i " + input + " phone.txt"); BufferedReader pin = new BufferedReader( new InputStreamReader(p.getInputStream())); String s; while ((s = pin.readline())!= null) result += \n" + s; pin.close(); } catch (IOException e) { result = "exec error ; } return result; }

GWT Widgets

Browser independence, almost Firefox Chrome

"Same Origin Policy" "The same origin policy prevents a document or script loaded from one origin from getting or setting properties of a document from another origin. This policy dates all the way back to Netscape Navigator 2.0." (Mozilla) "The SOP states that JavaScript code running on a web page may not interact with any resource not originating from the same web site." (Google) basically Javascript can only reference information from the site that provided the original code BUT: if a page loads Javascript from more than one site (e.g., as with cookies from third-party sites), then that JS code can interact with that third-party site

GWT assessment problem: Javascript is irregular, unsafe, not portable, easily abused solution: use Java, which is type-safe, standard, portable translate Java to Javascript to either be browser independent or tailored to specific browser as appropriate can take advantage of browser quirks, make compact code, discourage reverse engineering can provide standardized mechanisms for widgets, events, DOM access, server access, AJAX, RE's and other libraries,... in effect, treat each browser as a somewhat irregular machine and compile optimized code for it specifically

GWT vs Django focusing on different parts of the overall problem GWT provides reliable, efficient, browser-independent Javascript (from Java) extensive widget set no help with database access, generating HTML, Django provides no Javascript help no widgets easy database access; template language for generating HTML, easy linkage from URLs on web page to Python functions is GWT + App Engine a good combination?

Assessment of Web Frameworks advantages takes care of repetitive parts more efficient in programmer time automatically generated code is likely to be more reliable, have more uniformity of structure "DRY" (don't repeat yourself) is encouraged "single point of truth"... information is in only one place so it's easier to change things potential negatives automatically generated code can be hard to figure out what's going on can be hard to change if you don't want to do it their way systems are large and can be slow... read Joel Spolsky's "Why I hate frameworks" http://discuss.joelonsoftware.com/default.asp?joel.3.219431.12

Assessment of Ajax-based systems potential advantages can be much more responsive (cf Google maps) can off-load work from server to client code on server is not exposed continuous update of services potential negatives browsers are not standardized Javascript code is exposed to client Javascript code can be bulky and slow asynchronous code can be tricky DOM is very awkward browser history not maintained without effort what next? (changing fast) more and better libraries better tools and languages for programming better standardization? will the browser ever replace the OS?