Web Development Paradigms and how django and GAE webapp approach them.

Similar documents
django in the real world

From BASIS DD to Barista Application in Five Easy Steps

Basics HTTP. requests. Ryan E. Freckleton. PySprings. May 24, 2016

From BASIS DD to Barista Application in Five Easy Steps

Databases through Python-Flask and MariaDB

mylab: Chemical Safety Module Last Updated: January 19, 2018

Appendix B Microsoft Office Specialist exam objectives maps

Account Setup. STEP 1: Create Enhanced View Account

Crypto Lab 2011: Code Challenge Website - Report (v1.0)

SMS Support in Tally.CRM Table of Contents

Bentley Map V8i (SELECTseries 3)

Replication cluster on MariaDB 5.5 / ubuntu-server. Mark Schneider ms(at)it-infrastrukturen(dot)org

New Cloud Solutions by My TimeZero

Finnish Open Data Portal for Meteorological Data

M o n i t o r i n g O c e a n C o l o u r P y t h o n p r o c e d u r e f o r d o w n l o a d

SteelSmart System Cold Formed Steel Design Software Download & Installation Instructions

Extending MISP with Python modules MISP - Malware Information Sharing Platform & Threat Sharing

Tryton Technical Training

Agilent MassHunter Quantitative Data Analysis

ST-Links. SpatialKit. Version 3.0.x. For ArcMap. ArcMap Extension for Directly Connecting to Spatial Databases. ST-Links Corporation.

Bloomsburg University Weather Viewer Quick Start Guide. Software Version 1.2 Date 4/7/2014

A Practical Comparison of Agile Web Frameworks

Orienteering maps as a part of national heritage - the Czech case

putting communities in control of their neighbourhood plan using new technologies

Mass Asset Additions. Overview. Effective mm/dd/yy Page 1 of 47 Rev 1. Copyright Oracle, All rights reserved.

ChemmineR: A Compound Mining Toolkit for Chemical Genomics in R

D.T.M: TRANSFER TEXTBOOKS FROM ONE SCHOOL TO ANOTHER

Skyward. Requirements Specification Report. 12/7/2016 Version: 1.1. Team Name: Team Members: Sponsors: Mentor: Skyward

Notater: INF3331. Veronika Heimsbakk December 4, Introduction 3

GLAS Grond-laag Laser Adaptieve optiek Systeem Ground-layer Laser Adaptive optics System A Rayleigh laser beacon for NAOMI

Arboretum Explorer: Using GIS to map the Arnold Arboretum

Engineering for Compatibility

Introduction to ArcGIS Server Development

TENANT INSTRUCTOR REFERENCE GUIDE

ATLAS of Biochemistry

CHEMICAL INVENTORY ENTRY GUIDE

Extending MISP with Python modules MISP - Malware Information Sharing Platform & Threat Sharing

This introduction is intended for compliance officers at Protection Seller and Broker-Advisor firms

Performing Map Cartography. using Esri Production Mapping

Geodatabases and ArcCatalog

PI SERVER 2012 Do. More. Faster. Now! Copyr i g h t 2012 O S Is o f t, L L C. 1

Computer Complaints. Management System [CCMS] User Manual. This user Manual describes with Screen Shots the features and functionalities of CCMS

PC Control / Touch Control

Frequently Asked Questions

Geodatabase Best Practices. Dave Crawford Erik Hoel

ArcGIS Enterprise: What s New. Philip Heede Shannon Kalisky Melanie Summers Sam Williamson

Appendix 4 Weather. Weather Providers

HTEK IP Phones Configuration Guide for User Access Level of Web or LCD interface

OECD QSAR Toolbox v.4.1. Tutorial of how to use Automated workflow for ecotoxicological prediction

New SPOT Program. Customer Tutorial. Tim Barry Fire Weather Program Leader National Weather Service Tallahassee

COMS 6100 Class Notes

Yes, the Library will be accessible via the new PULSE and the existing desktop version of PULSE.

February 7, Jay Krafthefer, L.S.

Senior astrophysics Lab 2: Evolution of a 1 M star

Extending a Plotting Application and Finding Hardware Injections for the LIGO Open Science Center

Building Inflation Tables and CER Libraries

MCS 260 Exam 2 13 November In order to get full credit, you need to show your work.

Quick Reference Manual. Ver. 1.3

NovaToast SmartVision Project Requirements

GIS Functions and Integration. Tyler Pauley Associate Consultant

AFFH-T User Guide September 2017 AFFH-T User Guide U.S. Department of Housing and Urban Development

SirsiDynix Enterprise Training Guide

INTRODUCTION TO ARCGIS Version 10.*

What s New. August 2013

PebbleGo. Heritage Chris,an Schools Learning Commons

Mastering ArcGIS Platforms to Build a National Census Web Mapping Tool. Eoghan McCarthy (AIRO)

E23: Hotel Management System Wen Yunlu Hu Xing Chen Ke Tang Haoyuan Module: EEE 101

Presenting Tree Inventory. Tomislav Sapic GIS Technologist Faculty of Natural Resources Management Lakehead University

Example name. Subgroups analysis, Regression. Synopsis

new interface and features

BASIC TECHNOLOGY Pre K starts and shuts down computer, monitor, and printer E E D D P P P P P P P P P P

Dynamic Programming. Cormen et. al. IV 15

Arup Nanda Starwood Hotels

ON SITE SYSTEMS Chemical Safety Assistant

Leveraging Web GIS: An Introduction to the ArcGIS portal

Configuring LDAP Authentication in iway Service Manager

Kansas Next Generation 911

Using SkyTools to log Texas 45 list objects

Designing a Quilt with GIMP 2011

Leveraging ArcGIS Online Elevation and Hydrology Services. Steve Kopp, Jian Lange

Update and Modernization of Sales Tax Rate Lookup Tool for Public and Agency Users. David Wrigh

Lab 2 Worksheet. Problems. Problem 1: Geometry and Linear Equations

ArcGIS Enterprise: What s New. Philip Heede Shannon Kalisky Melanie Summers Shreyas Shinde

SuperCELL Data Programmer and ACTiSys IR Programmer User s Guide

Innovation. The Push and Pull at ESRI. September Kevin Daugherty Cadastral/Land Records Industry Solutions Manager

HOW TO ANALYZE SYNCHROTRON DATA

SOLAR MANTEL CLOCK MANUAL

Univariate Analysis of Variance

NV-DVR09NET NV-DVR016NET

Conceptual study of Web-based PPGIS for Designing Built Environment: Identifying Housing Location Preferences in Littleborough

FireFamilyPlus Version 5.0

Web GIS Administration: Tips and Tricks

Boolean and Vector Space Retrieval Models

Creating Questions in Word Importing Exporting Respondus 4.0. Importing Respondus 4.0 Formatting Questions

Homeland Security Geospatial Data Model. Mark Eustis SAIC Joe Kelly Traverse Technologies 21 February, 2008

Web GIS Based Disaster Portal Project ESRI INDIA

Enabling Web GIS. Dal Hunter Jeff Shaner

Continuous Performance Testing Shopware Developer Conference. Kore Nordmann 08. June 2013

Geodatabases and ArcCatalog

User's Manual altimeter V1.1

Transcription:

Web Development Paradigms and how django and GAE webapp approach them. Lakshman Prasad Agiliq Solutions September 25, 2010

Concepts and abstractions used to represent elements of a program

Web Development Paradigms: Modeling common web patterns

Why?

Batteries Included

docs.djangoproject.com

Webapp: Simple web application framework (with custom APIs)

Lets examine the batteries

How do I know about web development or django Active Djangonaut Part of a few popular open source django applications github.com/becomingguru, github.com/agiliq Consulting and Development via Developed several custom proprietory django applications @becomingguru

Introduction Forms Authentication Generic Views Caching Others Admin

Forms

Save form data to a table

Use a Model Form >>> from django. forms import ModelForm # C r e a t e the form c l a s s. >>> c l a s s A r t i c l e F o r m ( ModelForm ) :... c l a s s Meta :... model = A r t i c l e # C r e a t i n g a form to add an a r t i c l e. >>> form = A r t i c l e F o r m ( ) # C r e a t i n g a form to change an e x i s t i n g a r t i c l e. >>> a r t i c l e = A r t i c l e. o b j e c t s. get ( pk=1) >>> form = A r t i c l e F o r m ( i n s t a n c e=a r t i c l e )

Models

Model Syntax from django. db import models c l a s s Post ( models. Model ) : t i t l e = models. C h a r F i e l d ( max length =100) t e x t = models. T e x t F i e l d ( ) d a t e t i m e = models. DateTimeField ( ) c l a s s Meta : o r d e r i n g = ( d a t e t i m e, ) def u n i c o d e ( s e l f ) : return s e l f. t i t l e c l a s s Comment( models. Model ) : p o s t = models. ForeignKey ( Post ) t e x t = models. T e x t F i e l d ( )

Model API >>>from b l o g. models import Post, Comment >>>p o s t = Post. o b j e c t s. a l l ( ) [ 0 ] >>>post comments = p o s t. comment set. a l l ( )

Save Foreign Keys

Use Model Formset from django. forms. models import m o d e l f o r m s e t f a c t o r y AuthorFormSet = m o d e l f o r m s e t f a c t o r y ( Author ) f o r m s e t = AuthorFormSet ( ) >>> p r i n t f o r m s e t <i n p u t type= hidden name= form TOTAL FORMS v a l u e= 1 i d= i d f o r m TOTAL FORMS /> <i n p u t type= hidden name= form INITIAL FORMS v a l u e= 0 i d= i d f o r m INITIAL FORMS /> <i n p u t type= hidden name= form MAX NUM FORMS i d= i d f o r m MAX NUM FORMS /> <tr ><th> <l a b e l f o r= i d f o r m 0 name >Name:</ l a b e l > </th><td> <i n p u t i d= i d f o r m 0 name type= t e x t name= form 0 name maxlength= 100 /> </td></tr >

Model Formset options f o r m s e t = AuthorFormSet ( qs=author. o b j e c t s. a l l ( ), e x t r a =5) f o r m s e t. i s v a l i d ( ) f o r m s e t. e r r o r s { name : This f i e l d i s r e q u i r e d } f o r m s e t. changed forms f o r m s e t. s a v e ( )

Form pre populated

Forms dont have to save to a Model from django import forms c l a s s ContactForm ( forms. Form ) : s u b j e c t = forms. C h a r F i e l d ( max length =100) message = forms. C h a r F i e l d ( ) s e n d e r = forms. E m a i l F i e l d ( ) c c m y s e l f = forms. B o o l e a n F i e l d ( r e q u i r e d=f a l s e ) def s a v e ( s e l f ) : #Do a n y t h i n g...

Form Preview

Form Preview from django. c o n t r i b. f o r m t o o l s. p r e v i e w import FormPreview from myapp. models import SomeModel #Add a u r l ( r ˆ p o s t /$, SomeModelFormPreview ( SomeModelForm ) ), #D e f i n e form p r e v i e w c l a s s SomeModelFormPreview ( FormPreview ) : def done ( s e l f, r e q u e s t, c l e a n e d d a t a ) : # Do something with the c l e a n e d d a t a, then # r e d i r e c t to a s u c c e s s page. return H t t p R e s p o n s e R e d i r e c t ( / form / s u c c e s s )

Form Wizard

Form Wizard c l a s s ContactWizard ( FormWizard ) : def done ( s e l f, r e q u e s t, f o r m l i s t ) : d o s o m e t h i n g w i t h t h e f o r m d a t a ( f o r m l i s t ) return H t t p R e s p o n s e R e d i r e c t ( / r e d i r e c t / )

Authentication

Point to url pattern u r l p a t t e r n s += p a t t e r n s ( django. c o n t r i b. auth. v i e w s, u r l ( r ˆ l o g i n /$, l o g i n ), u r l ( r ˆ l o g o u t /$, l o g o u t ), u r l ( r ˆ r e g i s t e r /$, r e g i s t e r ), u r l ( r ˆ p a s s r e s e t /$, p a s s w o r d r e s e t ), u r l ( r ˆ p a s s r e s e t 2 /$, p a s s w o r d r e s e t d o n e ), u r l ( r ˆ p a s s r e s e t c o n f i r m /(?P<uidb36 >[ \w]+)/, p a s s w o r d r e s e t c o n f i r m ), u r l ( r ˆ p a s s r e s e t c o m p l e t e /$, p a s s w o r d r e s e t c o m p l e t e ), )

Login Required from django. c o n t r i b. auth. d e c o r a t o r s import \ l o g i n r e q u i r e d @ l o g i n r e q u i r e d ( r e d i r e c t f i e l d n a m e= r e d i r e c t t o ) def my view ( r e q u e s t ) :...

Authentication backends c l a s s S e t t i n g s B a c k e n d : A u t h e n t i c a t e a g a i n s t the s e t t i n g s ADMIN LOGIN and ADMIN PASSWORD. def a u t h e n t i c a t e ( s e l f, username=none, password=none ) i f l o g i n v a l i d and p w d v a l i d : return u s e r return None def g e t u s e r ( s e l f, u s e r i d ) : t r y : return User. o b j e c t s. get ( pk=u s e r i d ) except User. DoesNotExist : return None

django-socialauth

Send to template

Generic Views from django. c o n f. u r l s. d e f a u l t s import from django. v i e w s. g e n e r i c. s i m p l e \ import d i r e c t t o t e m p l a t e u r l p a t t e r n s = p a t t e r n s (, ( ˆ about /$, d i r e c t t o t e m p l a t e, { t e m p l a t e : about. html }) )

Object based generic views

Display objects and their lists from django. v i e w s. g e n e r i c. l i s t d e t a i l import \ o b j e c t d e t a i l, o b j e c t l i s t u r l ( ( r ˆ o b j e c t s / page (?P<page >[0 9]+)/$, o b j e c t l i s t, d i c t ( i n f o d i c t ) ), ( r ˆ o b j e c t s /(?P<id >[0 9]+)/$, o b j e c t d e t a i l, d i c t ( i n f o d i c t ) ), )

List of generic views django. v i e w s. g e n e r i c. s i m p l e. d i r e c t t o t e m p l a t e django. v i e w s. g e n e r i c. s i m p l e. r e d i r e c t t o django. v i e w s. g e n e r i c. l i s t d e t a i l. o b j e c t l i s t django. v i e w s. g e n e r i c. l i s t d e t a i l. o b j e c t d e t a i l django. v i e w s. g e n e r i c. c r e a t e u p d a t e. c r e a t e o b j e c t django. v i e w s. g e n e r i c. c r e a t e u p d a t e. u p d a t e o b j e c t django. v i e w s. g e n e r i c. c r e a t e u p d a t e. d e l e t e o b j e c t

Normalized data is for sissies - Cal Henderson

Different blocks need different caching durations

Generally Memcache Every page CACHE BACKEND = memcached : / / 1 2 7. 0. 0. 1 : 1 1 2 1 1 / CACHE BACKEND = memcached : / / 1 7 2. 1 9. 2 6. 2 4 0 : 1 1 2 1 1 ; \ 1 7 2. 1 9. 2 6. 2 4 2 : 1 1 2 1 2 ; 1 7 2. 1 9. 2 6. 2 4 4 : 1 1 2 1 3 /

Implement a caching decorator from django. c o r e. cache import cache def c a c h e f o r ( seconds, f e t c h =0): def c a c h e i t ( func ) : def d e c o f u n c ( s e l f ) : v a l = cache. get ( s e l f. g e t c a c h e k e y ( f e t c h ) ) i f not v a l : v a l = func ( s e l f ) cache. s e t ( s e l f. g e t c a c h e k e y ( f e t c h ), val, s e c o n d s ) return v a l return d e c o f u n c return c a c h e i t

Apply on the blocks c l a s s T w i t t e r B l o c k ( T w i t t e r S e a r c h B l o c k ) : template name = t w i t t e r u s e r b l o c k. html a j a x t e m p l a t e = t w e e t s u s e r. html @ c a c h e f o r (60 60, f e t c h =1) def f e t c h d a t a ( s e l f ) : tw = T w i t t e r ( e m a i l= umoja com ) u s e r t w e e t s = tw. s t a t u s e s. u s e r t i m e l i n e ( screen name=s e l f. data ) return u s e r t w e e t s, None

Different cache Backends Database File System Local Memory Dummy- For Development

More Paradigms Internationalization Localization Humanization CSRF Protection Pagination Sorting Data grid Sorl Thumbnail

Admin by models alone

Admin Syntax from django. c o n t r i b import admin from models import Post, Comment c l a s s PostAdmin ( admin. ModelAdmin ) : l i s t d i s p l a y = ( t i t l e, d a t e t i m e ) c l a s s CommentAdmin ( admin. ModelAdmin ) : l i s t d i s p l a y = ( t e x t, ) admin. s i t e. r e g i s t e r ( Post, PostAdmin ) admin. s i t e. r e g i s t e r (Comment, CommentAdmin )

List Page

Add an Entry

Auto Validation