Your SlideShare is downloading. ×
Deploying a Pylons app to Google App Engine
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Deploying a Pylons app to Google App Engine


Published on

A presentation at the Boston Python Users Group demonstrating how to build a Pylons app and deploy it to Google App Engine.

A presentation at the Boston Python Users Group demonstrating how to build a Pylons app and deploy it to Google App Engine.

Published in: Technology

  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide


  • 1. Deploying a Pylons app to Google App Engine Boston Python meetup - 6/18/08 Nate Aune 1
  • 2. Disclaimer #1 quot;I just started using Pylons last week.quot; 2
  • 3. Disclaimer #2 quot;I just started using Google App Engine last week.quot; 3
  • 4. App: Gigblastr • Goal: make it easier to promote an event • Fill out a form with event details • Blast event to dozens of event listing sites • Similar to TubeMogul but for events instead of videos. 4
  • 5. 5
  • 6. Musician Add event Title Poludaktulos Orchestra Description The Poludaktulos Orchestra (the quot;Many- Fingered Orchestraquot;) employs unique instrumentation in its lively performances of northern Greek brass band music. URL Venue Johnny D's Date 11/8/08 Start Time 9:00pm End 11:00pm Blast it! 6
  • 7. Brief history Implemented using content rules for Plone • version 0.1 @ DevHouseBoston3 2007 • posting to Twitter and Eventful • version 0.2 @ Home • posting to • version 0.3 @ DevHouseBoston4 2008 • rewrite as Pylons app deployed to GAE 7
  • 8. Bootstrap with the appenginemonkey $ svn co ape-monkey $ cd ape-monkey $ python2.5 --paste-deploy ~/gae/gigblastr $ cd ~/gae/gigblastr $ source bin/activate (gigblastr)$ easy_install Mako==dev Pylons==dev Paste ... (gigblastr)$ cd src (gigblastr)$ paster create --template=pylons GigBlastr (gigblastr)$ cd GigBlastr (gigblastr)$ python develop (gigblastr)$ python -m pth_relpath_fixup 8
  • 9. Configure your environment • Edit development.ini [app:the-app] use = config:src/GigBlastr/development.ini • Launch the application $ /usr/bin/python2.5 /usr/local/google_appengine/ ~/gae/gigblastr/ • Visit http://localhost:8080/ 9
  • 10. Edit the routes • In GigBlastr/config/ map.connect('', controller='hello', action='index') • Create a 'hello' controller $ paster controller hello • Restart and visit http://localhost:8080/hello/index 10
  • 11. Hello World import logging from pylons import request, response, session from pylons import tmpl_context as c from pylons.controllers.util import abort, redirect_to from gigblaster.lib.base import BaseController, render #import gigblaster.model as model log = logging.getLogger(__name__) class HelloController(BaseController): def index(self): # Return a rendered template # return render('/template.mako') # or, Return a response return 'Hello World' 11
  • 12. Twitter (gigblastr)$ easy_install python_twitter • In GigBlastr/controller/ import twitter def tweet(self): api = twitter.Api(username='natea', password='xxxxxxx') status = api.PostUpdate('testing tweets from GAE') return status.text • Restart and visit http://localhost:8080/hello/tweet/index 12
  • 13. Eventful (gigblastr)$ easy_install eventful • In GigBlastr/controller/ import eventful def evtful(self): api = eventful.API('xxxxxxxxxxxxx') events ='/events/search', q='music', l='Cambridge, MA') for event in events['events']['event']: print quot;%s at %squot; % (event['title'], event['venue_name']) • Restart and visit http://localhost:8080/hello/evtful/index 13
  • 14. Upload app to GAE $ cd gigblastr $ /usr/bin/python2.5 /usr/local/google_appengine/ update . • 973 files - whew! • If your app has more than 1000 files, you'll have to remove some unused eggs. 14
  • 15. Remove _speedups import simplejson File quot;/base/data/home/apps/gigblastr/1.8/lib/python2.5/site-packages/simplejson-1.8.1-py2.5-macosx-10.5-i386.egg/ simplejson/__init__.pyquot;, line 113, in <module> from encoder import JSONEncoder File quot;/base/data/home/apps/gigblastr/1.8/lib/python2.5/site-packages/simplejson-1.8.1-py2.5-macosx-10.5-i386.egg/ simplejson/encoder.pyquot;, line 6, in <module> from simplejson import _speedups File quot;/base/data/home/apps/gigblastr/1.8/lib/python2.5/site-packages/simplejson-1.8.1-py2.5-macosx-10.5-i386.egg/ simplejson/_speedups.pyquot;, line 7, in <module> __bootstrap__() File quot;/base/data/home/apps/gigblastr/1.8/lib/python2.5/site-packages/simplejson-1.8.1-py2.5-macosx-10.5-i386.egg/ simplejson/_speedups.pyquot;, line 5, in __bootstrap__ del __bootstrap__, __loader__ NameError: global name '__loader__' is not defined • Remove and from simplejson • They are trying to cache on the file system, which is a no-no on GAE. 15
  • 16. Guido, the creator of Python speaks! 16
  • 17. ianbicking to the rescue! Ian responds one week later 17
  • 18. Use httplib on GAE • In ## If you want to use httplib but get socket errors, ## you should uncomment this line: appengine_monkey.install_httplib() 18
  • 19. No Twitter from GAE :( 19
  • 20. More info • Google App Engine • Pylons • Instructions for Pylons on GAE • DevHouseBoston 20
  • 21. Thanks! • To Ian Bicking for making appengine- monkey, making the instructions, and helping on IRC. • The kind folks in #pylons who helped me get my head around Pylons syntax 21