Framework Presentation
-
Upload
rmalik2 -
Category
Technology
-
view
556 -
download
0
description
Transcript of Framework Presentation
![Page 1: Framework Presentation](https://reader036.fdocuments.in/reader036/viewer/2022062514/5594ed971a28ab965d8b46f7/html5/thumbnails/1.jpg)
Web Frameworks
By: Rahul Malik
![Page 2: Framework Presentation](https://reader036.fdocuments.in/reader036/viewer/2022062514/5594ed971a28ab965d8b46f7/html5/thumbnails/2.jpg)
What are they?
• In my opinion - “A software framework that is meant to remove the everyday pain and redundancy of web development.”
![Page 3: Framework Presentation](https://reader036.fdocuments.in/reader036/viewer/2022062514/5594ed971a28ab965d8b46f7/html5/thumbnails/3.jpg)
Awesome, what are my options??
![Page 4: Framework Presentation](https://reader036.fdocuments.in/reader036/viewer/2022062514/5594ed971a28ab965d8b46f7/html5/thumbnails/4.jpg)
Ruby on Rails (RoR)• Made at 37 Signals by
DHH
• Paved the way for framework development in many other languages
• Written in Ruby
• Credited with people finding out about ruby
!"#$%&'&$ ())* +,
![Page 5: Framework Presentation](https://reader036.fdocuments.in/reader036/viewer/2022062514/5594ed971a28ab965d8b46f7/html5/thumbnails/5.jpg)
Django
• Written in Python
• Similar philosophies as Rails except they stress modularity
• Made in Kansas at The World Company
!"#$%&'&$ ())* +,
-$./0#12
345&645#$12
![Page 6: Framework Presentation](https://reader036.fdocuments.in/reader036/viewer/2022062514/5594ed971a28ab965d8b46f7/html5/thumbnails/6.jpg)
Why do we need them?• Web Programming was a black art
• Bad Practices were formed
• High coupling of components
• Mind numbing processes had to be done repeatedly. (i.e. CRUD pages)
• Infrastructure specific (switching to Oracle = pain)
![Page 7: Framework Presentation](https://reader036.fdocuments.in/reader036/viewer/2022062514/5594ed971a28ab965d8b46f7/html5/thumbnails/7.jpg)
How do they fix these problems?
![Page 8: Framework Presentation](https://reader036.fdocuments.in/reader036/viewer/2022062514/5594ed971a28ab965d8b46f7/html5/thumbnails/8.jpg)
Model View Controller Design
Model Controller View
![Page 9: Framework Presentation](https://reader036.fdocuments.in/reader036/viewer/2022062514/5594ed971a28ab965d8b46f7/html5/thumbnails/9.jpg)
Model
![Page 10: Framework Presentation](https://reader036.fdocuments.in/reader036/viewer/2022062514/5594ed971a28ab965d8b46f7/html5/thumbnails/10.jpg)
Database Management
• Object Relational Mapping (ORM)
• Switching to another database type is just changing a flag
• Transaction support as well as database migrations
![Page 11: Framework Presentation](https://reader036.fdocuments.in/reader036/viewer/2022062514/5594ed971a28ab965d8b46f7/html5/thumbnails/11.jpg)
Database Management
class Entry(models.Model): pub_date = models.DateTimeField() slug = models.SlugField(unique_for_date='pub_date') headline = models.CharField(maxlength=200) summary = models.TextField(help_text="Use raw HTML.") body = models.TextField(help_text="Use raw HTML.") author = models.CharField(maxlength=100)
Entry.objects.get(headline=’framework talk’)
Entry.objects.filter(pub_date=datetime.now())
![Page 12: Framework Presentation](https://reader036.fdocuments.in/reader036/viewer/2022062514/5594ed971a28ab965d8b46f7/html5/thumbnails/12.jpg)
View
![Page 13: Framework Presentation](https://reader036.fdocuments.in/reader036/viewer/2022062514/5594ed971a28ab965d8b46f7/html5/thumbnails/13.jpg)
Template Systems!
• Simple systems that can be used to generate HTML, CSS, RSS, or any other text based formats
• Controller provides context and separation from model
• Good for designers
![Page 14: Framework Presentation](https://reader036.fdocuments.in/reader036/viewer/2022062514/5594ed971a28ab965d8b46f7/html5/thumbnails/14.jpg)
Template Systems
{% extends "creator/base.html" %}{% block content %}<h1>User Settings</h1><h2>{{ user.username }}</h2><form action="." method="post">{{ form.as_p }}<input type="submit" value="Save Changes" /></form>{% endblock %}
![Page 15: Framework Presentation](https://reader036.fdocuments.in/reader036/viewer/2022062514/5594ed971a28ab965d8b46f7/html5/thumbnails/15.jpg)
Controller
![Page 16: Framework Presentation](https://reader036.fdocuments.in/reader036/viewer/2022062514/5594ed971a28ab965d8b46f7/html5/thumbnails/16.jpg)
Sexy URL’s
• blog.php?month=11&day=19&year=2008
• blog/11/19/2008/
![Page 17: Framework Presentation](https://reader036.fdocuments.in/reader036/viewer/2022062514/5594ed971a28ab965d8b46f7/html5/thumbnails/17.jpg)
Request Routing
• All HTTP Requests get mapped to a controller or 404 by naming conventions (rails) or regex matching (django)
• domain.com/blog/view/getvar1/getvar2/...
• '^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?P<slug>[\w-]+)/$'
![Page 18: Framework Presentation](https://reader036.fdocuments.in/reader036/viewer/2022062514/5594ed971a28ab965d8b46f7/html5/thumbnails/18.jpg)
Request Routing
• Naming Conventions vs. Regex Matching
• What else to you get?
• GET, POST variables, as much HTTP Header information that you could want
![Page 19: Framework Presentation](https://reader036.fdocuments.in/reader036/viewer/2022062514/5594ed971a28ab965d8b46f7/html5/thumbnails/19.jpg)
URL Matching (Regex)
from feeds.views import publish_templatized_feed_item, publish_feed_item, refresh_feed
urlpatterns = patterns('', (r'^publish/$', publish_feed_item), (r'^publish/template/$', publish_templatized_feed_item), (r'^refresh/$', refresh_feed))
![Page 20: Framework Presentation](https://reader036.fdocuments.in/reader036/viewer/2022062514/5594ed971a28ab965d8b46f7/html5/thumbnails/20.jpg)
URL Matching (regex)urlpatterns = patterns('django.views.generic.date_based',
(r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?P<slug>[\w-]+)/$', 'object_detail', dict(info_dict, slug_field='slug')),
(r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/$', 'archive_day', info_dict),
(r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/$', 'archive_month', info_dict),
(r'^(?P<year>\d{4})/$', 'archive_year', info_dict),
(r'^/?$', 'archive_index', info_dict),)
![Page 21: Framework Presentation](https://reader036.fdocuments.in/reader036/viewer/2022062514/5594ed971a28ab965d8b46f7/html5/thumbnails/21.jpg)
Freebies
![Page 22: Framework Presentation](https://reader036.fdocuments.in/reader036/viewer/2022062514/5594ed971a28ab965d8b46f7/html5/thumbnails/22.jpg)
Automation
• CRUD or Admin interfaces
• Schema Upgrades and Downgrades (Migrations)
• Generating Frequent Components (new controller, model, etc.)
![Page 23: Framework Presentation](https://reader036.fdocuments.in/reader036/viewer/2022062514/5594ed971a28ab965d8b46f7/html5/thumbnails/23.jpg)
Security
• Authorization and Authentication of users built-in!
• Permissions Models
• Basic Web Security at it’s core (SQL Injection, CSRF, etc.)
![Page 24: Framework Presentation](https://reader036.fdocuments.in/reader036/viewer/2022062514/5594ed971a28ab965d8b46f7/html5/thumbnails/24.jpg)
Caching
• Simple hooks and/or helpers baked in
• Flat-File, Database, or Distributed (memcached) database management
![Page 25: Framework Presentation](https://reader036.fdocuments.in/reader036/viewer/2022062514/5594ed971a28ab965d8b46f7/html5/thumbnails/25.jpg)
But does it scale?
![Page 26: Framework Presentation](https://reader036.fdocuments.in/reader036/viewer/2022062514/5594ed971a28ab965d8b46f7/html5/thumbnails/26.jpg)
Yes
![Page 27: Framework Presentation](https://reader036.fdocuments.in/reader036/viewer/2022062514/5594ed971a28ab965d8b46f7/html5/thumbnails/27.jpg)
Any Other Questions?