【笔记2】CS253: WEB APPLICATION ENGINEERING

You Servers GET form form HTML POST answer redirect GET success Success HTML You Servers
  • self.redirect(’/thanks’)
	import cgi
	cgi.escape(s, quote=True)
	username = self.request.get('username')
	USER_RE = re.compile(r'^[a-zA-Zd0-9_-{3,20}$')
	USER_RE.match(username)
	PASS_RE = re.compile(r'^.{3,20}$')
	EMAIL_RE = re.compile(r'^[\S]+@[\S]+\.[\S]+$')
  • html_template
  • Django_template

Database: large, structured data

User Internet Servers Database User Internet Servers Database
Tables
Link:IDvotesuserdatatitleurl
User:Usernamepasswordemail
  • downsides of query
    error_prone, tedious, slow

  • types of databases

    • Rational SQL
      • Postgre SQL - FREE
      • MySQL - FREE
      • SQLite (Light weight)
      • Oracle (take from MySQL)
  • GAE’s Datastore

    • Dynamo (Amazon) [Read Paper!]
    • NoSQL
      • mongo
      • couch
  • SQL

    • SELECT * FROM links WHERE id=5
  • Indexes (speed queries / slow inserts)

    • dict in python
      • hash - not sorted, lookup const time
      • time - sorted, lookup log(n) time
  • Scaling Databases (too much load)

    • master - slaves(replicate) - downsides
      • doesn’t increase write speed
      • replication lag
    • shard (分割) - hash - downsides
      • complex queries (range query)
      • joins become difficult
    • GAE Datastore
      • joins
      • complex queries
      • tables -> entities
        • columns are NOT fixed
        • all have an ID
        • parents/ancestors (Reddit->Link)
  • ACID

    • Atomicity - transaction (multiple cmds)
    • Consistency - synchronize updating
    • Isolation - lock/not interference
    • Durability - once committed, wait loss
  • SQL -> GQL

    • ALL queries begin with SELECT *
    • No joins
    • run arbitrary queries -> all queries MUST be indexed
  • Datastore is sharded & replicated

    • won’t think (too much) about scaling
    • quick queries (because simple)
    • will have to think about consistency
  • ASCII chan

    • Datastore Types
      • Integer
      • Float
      • String (<500 chars indexed)
      • Date
      • Time
      • DateTime
      • Email
      • Link
      • PostalAddress
      • Text (>500 chars NOT indexed)
dev_appserver.py
appcfg.py

SLAC & big data, Mozilla, open source

  1. abstraction
    • variable
    • procedure
    • list
    • search index
    • network
    • dict
    • hash
  2. universality
    • if
    • variable
    • while procedure
  3. recursive definitions

What is CS?

  1. Engineering ( abstraction <-> constraint of human thought )
  2. Science ( computation in nature universality )
  3. Liberal Art ( 7 branches )

(class for db)
p = Post(title, content)
p.key().id() == 42
p = Post.get_by_id(42)

  • DON’T user JOIN
  • Make things independent
	def foo(*a):
		return a
	>> foo()
	>> ()

	def render(*a, **kw):
		return a, kw
	>> render(1, 2, 3)
	>> ((1, 2, 3), {})
  • Framework (Quite similar)
    • Django for python
    • Ruby on Rails
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值