an app in a week

82
An app in a week http://marcinkaszynski.com

Upload: guest18915c

Post on 23-Jan-2015

3.372 views

Category:

Technology


1 download

DESCRIPTION

A talk about creating web applications fast, given at Europython2008.

TRANSCRIPT

Page 1: An app in a week

An app in a week

http://marcinkaszynski.com

Page 2: An app in a week

new site each monthrelease in a week

Page 3: An app in a week

http://favpico.com/

http://webcomicspot.com/

http://oiola.com/

hey, cool,

it worked

!

Page 4: An app in a week

created FAST

Page 5: An app in a week

20 minutes7 days

Page 6: An app in a week

decidebuild

rebuildthrow away

repeat

Page 7: An app in a week

on to the work

Page 8: An app in a week

The problem

it is cumbersome to gather the list of attendees to an

event

Page 9: An app in a week

imprezra list of events

attendee registrations(oiola--)

Page 10: An app in a week

General rules

1. avoid work

Page 11: An app in a week

start with a framework

URL resolver/mapper

internationalization

form handling

templates

ORM

Page 12: An app in a week

look for libraries

code only when absolutely necessary

Page 13: An app in a week

directory: imprezr/

settings.py

urls.py

manage.py

Page 14: An app in a week

settings.py

Page 15: An app in a week

settings.py

Page 16: An app in a week

urls.py

Page 17: An app in a week
Page 18: An app in a week

kickstart

Page 19: An app in a week
Page 20: An app in a week
Page 21: An app in a week
Page 22: An app in a week
Page 23: An app in a week

commit early, commit often

Page 24: An app in a week

development cycle starts

Page 25: An app in a week

directory: events/

models.py

views.py

Page 26: An app in a week

events/models.py

Page 27: An app in a week

events/models.py

Page 28: An app in a week

settings.py

Page 29: An app in a week
Page 30: An app in a week
Page 31: An app in a week
Page 32: An app in a week
Page 33: An app in a week

fully functional admin interface

create, change, delete stuff

permission control

userX

Page 34: An app in a week

customization

ModelAdmin:queryset – limit the list__call__ – add views

CSS, templates – change the looks

Page 35: An app in a week
Page 36: An app in a week

public views

/ - event list

/123/ - event details

/123/register/ - registration form

Page 37: An app in a week

urls.py – generic views

Page 38: An app in a week
Page 39: An app in a week

templates/events/event_list.html

templates/base.html

Page 40: An app in a week

templates/events/event_detail.html

Page 41: An app in a week

event list

Page 42: An app in a week

event detail

Page 43: An app in a week

registration form

Page 44: An app in a week

urls.py

Page 45: An app in a week

events/views.py

Page 46: An app in a week

templates/events/register.html

Page 47: An app in a week

templates/events/event_details.html

Page 48: An app in a week
Page 49: An app in a week

cooperation

code sharing: only via VCS

Page 50: An app in a week

Instant Django

theory:„everything you need to learn the basics

of the Django framework”

practice:the easiest way to share complete Django development environments on Windows

Python + Django + sqlite

Page 51: An app in a week

Instant Django

1. checkout your source code2. add libraries (possibly using VCS, like

svn:externals)3. automate DB upgrades

Page 52: An app in a week

„how should I call it?”„what did you call it?”„where did you put it?”

all mean lost time

conventions

example: template names

Page 53: An app in a week

renders „app_name/view_name.html”

Page 54: An app in a week
Page 55: An app in a week

tests

they DO save time

Page 56: An app in a week
Page 57: An app in a week
Page 58: An app in a week
Page 59: An app in a week

some shortcuts – get, post, find

Page 60: An app in a week
Page 61: An app in a week
Page 62: An app in a week

further reading

BeautifulSoup – navigation, searchingfindAll

Page 63: An app in a week

testing the tests

coverage.py finds:untested code

dead code

Page 64: An app in a week
Page 65: An app in a week

false positives

small code changes requiredincredibly helpful anyway

Page 66: An app in a week

first user responses

registration sucks:too little data (first name, last name)

Page 67: An app in a week

events/models.py

events/views.py

add first_name and last_name

Page 68: An app in a week

some ALTERing necessary

Page 69: An app in a week

deseb

Django External Schema Evolution BranchADDs, ALTERs and DROPsworks around DB limitations

Page 70: An app in a week

settings.py

adds new commands to manage.pysqlevolveevolvedb

Page 71: An app in a week

evolvedb

Page 72: An app in a week

flashback: Instant Django

1. checkout your source code2. add libraries (possibly using VCS, like

svn:externals)3. automate DB upgrades

Page 73: An app in a week

broke the tests, too

events/tests.py

Page 74: An app in a week

done

Page 75: An app in a week

cycle continues

goto 10

Page 76: An app in a week

user accounts

django-registrationdjango-userprofile

django-authopenid

Page 77: An app in a week

openid

great for tech-savvy usersdifficult for other audiences

Page 78: An app in a week

settings.py

urls.py

django_authopenid/views.py (twice)

Page 79: An app in a week

1. copy django/contrib/admin/templates/admin/login.html

to imprezr/templates/admin/login.html

2. add the following form

the login page

Page 80: An app in a week

the result

Page 81: An app in a week

work avoidanceDjango user interface

conventionsInstant Django

testing the codetesting the tests

desebdjango_authopenid

summary

Page 82: An app in a week

http://marcinkaszynski.com