gargant.dispatch, a flexible dispatcher for WSGI
Upcoming SlideShare
Loading in...5
×
 

gargant.dispatch, a flexible dispatcher for WSGI

on

  • 503 views

Talking about gargant.dispatch, dispatcher library for WSGI applications.

Talking about gargant.dispatch, dispatcher library for WSGI applications.

https://pypi.python.org/pypi/gargant.dispatch

Statistics

Views

Total Views
503
Views on SlideShare
486
Embed Views
17

Actions

Likes
0
Downloads
0
Comments
0

1 Embed 17

https://twitter.com 17

Accessibility

Upload Details

Uploaded via as Adobe PDF

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

gargant.dispatch, a flexible dispatcher for WSGI gargant.dispatch, a flexible dispatcher for WSGI Presentation Transcript

  • gargant.dispatch a flexible dispatcher for WSGI @hirokiky
  • @hirokiky Contributing to Django, django-localflavor Admin of djangoproject.jp BePROUD Inc
  • Talk about pure WSGI library Not Django
  • Pure WSGI dispatcher urlrelay example code by WSGI.org WebDispatch
  • gargant.dispatch A dispatcher for WSGI application. now available on PyPI 2.7, 3.3 support
  • Basic usage Creating tree >>> from gargant.dispatch import Node, path_matching >>> from path.to.yours import wsgi_app >>> tree = Node((path_matching(['']),), ...             case=wsgi_app, ...             name='first')              Base setting (a.k.a Routing) path.to.yours.wsgi_app will be called when PATH_INFO='/'
  • Basic usage And creating WSGI app >>> from wsgiref.simple_server import make_server >>> from gargant.dispatch import make_wsgi_app >>> app = make_wsgi_app(tree) >>> httpd = make_server('', 8000, app) >>> httpb.serve_forever()             
  • Node gargant.dispatch.Node is not just for creating a WSGI application. >>> tree = Node((path_matching(['']),), ...             case='dolls') >>> node = tree({'PATH_INFO': '/'}) >>> node.case  # 'dolls'             
  • Hierarchy >>> tree = Node((path_matching(['']),), ...             case='dolls', ...             children=( ...                 Node((path_matching['fifth']), ...                      case='shinku'), ...             )) >>> >>> node = tree({'PATH_INFO': '/fifth'}) >>> node.case  # 'shinku' >>> node = tree({'PATH_INFO': '/'}) >>> node.case  # 'dolls'             
  • Matching matchings is not only path_matching >>> tree = Node((path_matching(['']), ...             method_matching('get'), ...             lambda environ: True), ...             case='dolls', ...             ) >>> >>> node = tree({'PATH_INFO': '/', ...              'REQUEST_METHOD': 'GET'}) >>> node.case  # 'dolls'              matchings return function handling environ All of matchings return values (as bool True), the node will be matched
  • URL args node.metched is values returned by matchings >>> tree = Node((path_matching(['']),), ...             case='doll_list', ...             children=( ...                 Node((path_matching(['{doll}']),), ...                       case='doll_detail', ...                 ), ...             )) >>> >>> node = tree({'PATH_INFO': '/first'}) >>> node.case  # 'doll_detail' >>> node.matched[0]['doll']  # 'first'             
  • and more... Adaptation of each path iteration leaf node to root node Getting URL from node.name (future)
  • Let's write dispatcher gargant.dispach is experimental/for education project please give me your feedback
  • thanks gargant.dispatch @hirokiky