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



Similar documents
Online shopping store

Module Private Sales User Manual

Introduction to FreeNAS development

SMSNotify Extension. User Documentation. Automated SMS sender and customer relationship tool. SMSNotify User Documentation 1

Clutch Magento Extension Installation Guide Installation and Testing Steps for Utilizing Gift & Stored Value Functionality

Secure Messaging Server Console... 2

ADT: Inventory Manager. Version 1.0

ADT: Bug Tracker. Version 1.0

Web Frameworks. web development done right. Course of Web Technologies A.A. 2010/2011 Valerio Maggio, PhD Student Prof.

Creating a generic user-password application profile

TABLE OF CONTENTS. 1) Introduction 2. 2) Installation 3. 3) Backend functionality 4. 4) Frontend functionality 9

DNNSmart Super Store User Manual

After many years we are happy to create a new social plugin with a great potential.

EM Single Sign On 1.2 (1018)

Django Two-Factor Authentication Documentation

>

django-cron Documentation

E-Commerce Threat Model using ThreatModeler

Authorize.NET Setup Guide

Facebook - Twitter - Google +1 all in one plugin for Joomla enable "Twitter button", "Google +1

User's Guide. Using RFDBManager. For 433 MHz / 2.4 GHz RF. Version

Introduction to Django Web Framework

HTSQL is a comprehensive navigational query language for relational databases.

Managing Qualys Scanners

Top Navigation menu - Tabs. User Guide 1. &

AUTHENTICATION... 2 Step 1:Set up your LDAP server... 2 Step 2: Set up your username... 4 WRITEBACK REPORT... 8 Step 1: Table structures...

Website Builder Quick Start. This document describes the API calls and steps needed to get started using the enom Website Builder.

Manual. Version: 1.0.0

Error and Event Log Messages

Nevepoint Access Manager 1.2 BETA Documentation

Magento module Documentation

External Authentication with Juniper SSL VPN appliance Authenticating Users Using SecurAccess Server by SecurEnvoy

Samsung KNOX EMM Authentication Services. SDK Quick Start Guide

DjNRO Release 0.9 July 14, 2015

PROPOSED SOLUTIONS FOR THE DESIGN & DEVELOPMENT OF COUPON WEBSITE

Oracle Application Express MS Access on Steroids

NODE4 SERVICE DESK SYSTEM

easy_review version BoostMyShop

Web Framework Performance Examples from Django and Rails

Citrix Worx App SDK Overview

Python and Google App Engine

MAGEJAM PLUGIN INSTALLATION GUIDE

CounterPoint SQL and Magento ecommerce Interface

The Ultimate Guide to Magento SEO Part 1: Basic website setup

Chapter 5 Configuring the Remote Access Web Portal

Hints for Service Oriented Architectures. Marius Twitter Inc.

Version 4.0 MageB2B Pricesystem ReadMe AIRBYTES GmbH

Load testing with. WAPT Cloud. Quick Start Guide

!!!!!!!! Startup Guide. Version 2.7

rma_product_return version BoostMyShop

Optimizing Drupal Performance. Benchmark Results

Amazon Web Services Yu Xiao

ARUBA WIRELESS AND CLEARPASS 6 INTEGRATION GUIDE. Technical Note

Additional details >>> HERE <<<

Camilyo APS package by Techno Mango Service Provide Deployment Guide Version 1.0

Startup Guide. Version 2.3.9

PKI for Electronic Commerce

Magento Extension for Add Multiple Products by Capacity Web Solutions

LICENTIA. InvoiceXpress Integration

IdentityGuard 8.1 Programming Guide for the.net Framework

Advanced Tornado TWENTYONE Advanced Tornado Accessing MySQL from Python LAB

ipad or iphone with Junos Pulse and Juniper SSL VPN appliance Authenticating Users Using SecurAccess Server by SecurEnvoy

design coding monitoring deployment Java Web Framework for the Efficient Development of Enterprise Web Applications

3dCart Shopping Cart Software Release Notes Version 3.0

SelectSurvey.NET Basic Training Class 1

Brainshark/Salesforce.com Integration Installation Procedures

Advanced Web Development SCOPE OF WEB DEVELOPMENT INDUSTRY

Use Enterprise SSO as the Credential Server for Protected Sites

Content Management System

Mirantis

Collaborative Document Review System for Community Engagement

WordPress Security Scan Configuration

Integrating LivePerson with Salesforce

Installation & Configuration Guide Version 2.2

Newsletter Popup PRO

Deploying RSA ClearTrust with the FirePass controller

Additional information >>> HERE <<< Online Book Premium WordPress Plugin Developer - Plugin Dynamo

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

Automate Your BI Administration to Save Millions with Command Manager and System Manager

BDD FOR AUTOMATING WEB APPLICATION TESTING. Stephen de Vries

ekomimeetsmage Manual for version 1.0.0, 1.1.0, 1.2.0, 1.3.0, 1.4.0

LICENSE4J AUTO LICENSE GENERATION AND ACTIVATION SERVER USER GUIDE

Cloud Application Development (SE808, School of Software, Sun Yat-Sen University) Yabo (Arber) Xu

Django-nonrel Documentation

SOA, case Google. Faculty of technology management Information Technology Service Oriented Communications CT30A8901.

Red Hat Mobile Application Platform

About the Authors About the Technical Reviewer

Pillars of Python: Six Python Web frameworks compared

by

System Admin Module User Guide. Schmooze Com Inc.

Management Authentication using Windows IAS as a Radius Server

McAfee Cloud Identity Manager

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

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 ( / page to r e d i r e c t to

Authentication

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

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 from django. c o n f import s e t t i n g s from django. c o n t r i b. auth. models import User, c h e c k p a s s w 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 AD 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 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 = c o n t e n t b l o c k a p p / t w i t t e r u s e r b l o c k a j a x t e m p l a t e = c o n t e n t b l o c k a p p / 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 ) : import b e t t e r t w i t t e r tw = b e t t e r t w i t t e r. T w i t t e r ( e m a i l= umoja com, pas 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 na return u s e r t w e e t s, None

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

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