WSGI, Repoze, Deliverence
Upcoming SlideShare
Loading in...5
×
 

WSGI, Repoze, Deliverence

on

  • 3,323 views

 

Statistics

Views

Total Views
3,323
Views on SlideShare
3,295
Embed Views
28

Actions

Likes
1
Downloads
37
Comments
0

3 Embeds 28

http://www.plug.org.ua 11
http://www.slideshare.net 10
http://plug.org.ua 7

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

WSGI, Repoze, Deliverence WSGI, Repoze, Deliverence Presentation Transcript

  • WSGI, Repoze, Deliverence Mykola Kharechko © Quintagroup, 2008
  • Overview
    • Connection between WSGI, Repoze, Deliverance
    • WSGI
    • Repoze
    • Deliverance
  • Connection between WSGI, Repoze, Deliverance WSGI WSGI Zope Repoze Deliverance
  • WSGI – The Problem ● Lots of web frameworks: Zope, Quixote, Webware, SkunkWeb and Twisted Web etc. ● Applications written for one framework often weren't compatible with the server components of the others ● Made the choosing a Python web framework hard as there were so many different and incompatible options ● The PEP compares the situation to Java which had its Servelet API
  • WSGI `Hello World`
    • from wsgiref import simple_server
    • def app(env, start_response):
    • start_response('200 OK', [('Content-type', 'text/html')])
    • return ['<h1>Hello, World!</h1>']
    • server=simple_server.make_server('', 8000, app)
    • server.serve_forever()
  • What makes this a WSGI application
    • ● It is a callable (in this case a simple function)
    • taking environ and start_response as
    • positional parameters.
    • ● It calls start_response() with a status code
    • and a list of tuple pairs of headers before it
    • returns a value. It should only be called
    • once.
    • ● The response it returns is an iterable (in this
    • case a list with just one string).
  • WSGI - Middleware 1. Acts like a WSGI application 2. Follows the WSGI Spec 3. Looks like a server to another piece of middleware or an application 4. Could decide to give its own response, or call your app
  • WSGI Middleware Example try: my_app_resp = my_app(env, my_start_response) start_response(status, header) except: start_response('500 Internal error', some_headers) my_app_resp = ['Sorry'] return my_app_resp
  • WSGI Summary ● WSGI isn't too complicated ● If your app is WSGI compliant you can instantly deploy it on a number of servers ● There are lots of powerful tools and middleware already in existence and you can easily re-use them -> see wsgi.org ● I'll be talking about Pylons later today which is one of the first projects to use WSGI throughout its stack.
  • Repoze – The Problem
    • Zope isn't compatible with WSGI
  • Top-Level Packages
    • repoze.zope2
    • repoze.plone
    • repoze.grok
  • repoze.zope2
    • Re-implementation of Zope 2's ZPublisher to fit into a WSGI stack &quot;natively&quot;.
    • As a result, run Zope2 within Apache using mod_wsgi.
    • Goal: 100% backwards compatibility with all Zope 2 products.
    • Goal: 100% egg-based package installation.
    • Goal: move many Zope 2 features out into middleware.
  • Repoze - Installing and Starting
    • easy_install and virtualenv based via http://repoze.org/quickstart.html.
    • Buildout-based via http://svn.repoze.org/buildouts.
    • bin/paster serve etc/zope2.ini
  • Motivation to Deliverance
    • Zope and Content Management System forces web designers to learn a complex page templating language. It makes designing web pages slow to develop and hard to debug. There should be an easier way to take the content from a CMS and style it in various ways without understanding the architecture of the CMS and without even knowing the origin of the content. This would create a formal distinction between content production and content delivery.
  • Deliverance Components
    • The content is the information you want to style with the theme. It can be a live website or a static file, specified with a URI.
    • The theme contains the style and layout information you want to apply to the content. It can be a live website or a static file, specified with a URI.
    • The rules tell Deliverance how to apply the theme to the content.
  • Introduction example
    • Content: <html><body><div id=&quot;bar&quot;>Real Content</div></body></html>
    • Theme:<html><head><title>Blah</title></head><body><div id=&quot;foo&quot;>Dummy Content</div></body></html>
    • Rule: <replace theme=&quot;//div[@id='foo']&quot; content=&quot;//div[@id='bar']&quot; />
    • Result:<html><head><title>Blah</title></head><body><div id=&quot;bar&quot;>Real Content</div></body></html>
  • Deliverance. Simple Example. Page with content <html> <head> <title>my boring todo page</title> <head> <body> <div id=&quot;todo&quot;> <h1>Things To Do</h1> <ul> <li>Feed the cat</li> <li>Wash the dishes</li> </ul> </div> </body> </html>
  • Deliverance. Simple Example. Page with theme <html> <head> <style type=&quot;text/css&quot;> div {background: #00ffdd;} li {list-style-type: disc;} </style> <title>my exciting home page</title> </head> <body> <h1>Deliverance User's Exciting Page</h1> <div id=&quot;wishes&quot;> I wish my todo list looked this cool </div> </body> </html>
  • Deliverance. Simple Example. Rule File <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <rules xmlns=&quot;http://www.plone.org/deliverance&quot; > <replace theme=&quot;//div[@id='wishes']&quot; content=&quot;//div[@id='todo']&quot; /> </rules>
  • Deliverance. Simple Example. Output div {background: #00ffdd;} li {list-style-type: disc;} </style> <title>my exciting home page</title> </head> <body> <h1>Deliverance User's Exciting Page</h1> <div id=&quot;todo&quot;> <h1>Things To Do</h1> <ul> <li>Feed the cat</li> <li>Wash the dishes</li> <ul>
  • Deliverance directives
    • append-or-replace
    • replace
    • move
    • copy
    • prepend
    • drop
  • Deliverance. Interacting with other wsgi applications Some WSGI-app with html content Deliverance Theme site Browser
  • Deliverence Problems
    • Does not work with curve/wrong HTML
    • Includes only basic XSL Transformations
    • XPath requires additional library
  • The End