Framework Presentation

685 views
605 views

Published on

11-19-2008, talk given in CS491 Web Seminar at UIUC

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
685
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
43
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Framework Presentation

  1. 1. Web Frameworks By: Rahul Malik
  2. 2. What are they? • In my opinion - “A software framework that is meant to remove the everyday pain and redundancy of web development.”
  3. 3. Awesome, what are my options??
  4. 4. 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 !quot;#$%&'&$ ())* +, finding out about ruby
  5. 5. Django • Written in Python -$./0#12 • Similar philosophies as Rails except they stress modularity • Made in Kansas at The 345&645#$12 World Company !quot;#$%&'&$ ())* +,
  6. 6. 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)
  7. 7. How do they fix these problems?
  8. 8. Model View Controller Design Model Controller View
  9. 9. Model
  10. 10. Database Management • Object Relational Mapping (ORM) • Switching to another database type is just changing a flag • Transaction support as well as database migrations
  11. 11. 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=quot;Use raw HTML.quot;) body = models.TextField(help_text=quot;Use raw HTML.quot;) author = models.CharField(maxlength=100) Entry.objects.get(headline=’framework talk’) Entry.objects.filter(pub_date=datetime.now())
  12. 12. View
  13. 13. 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
  14. 14. Template Systems {% extends quot;creator/base.htmlquot; %} {% block content %} <h1>User Settings</h1> <h2>{{ user.username }}</h2> <form action=quot;.quot; method=quot;postquot;> {{ form.as_p }} <input type=quot;submitquot; value=quot;Save Changesquot; /> </form> {% endblock %}
  15. 15. Controller
  16. 16. Sexy URL’s • blog.php?month=11&day=19&year=2008 • blog/11/19/2008/
  17. 17. 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-]+)/$'
  18. 18. Request Routing • Naming Conventions vs. Regex Matching • What else to you get? • GET, POST variables, as much HTTP Header information that you could want
  19. 19. 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) )
  20. 20. 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), )
  21. 21. Freebies
  22. 22. Automation • CRUD or Admin interfaces • Schema Upgrades and Downgrades (Migrations) • Generating Frequent Components (new controller, model, etc.)
  23. 23. Security • Authorization and Authentication of users built-in! • Permissions Models • Basic Web Security at it’s core (SQL Injection, CSRF, etc.)
  24. 24. Caching • Simple hooks and/or helpers baked in • Flat-File, Database, or Distributed (memcached) database management
  25. 25. But does it scale?
  26. 26. Yes
  27. 27. Any Other Questions?

×