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

6,781
views

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

0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
6,781
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
77
Comments
0
Likes
4
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Deploying a Pylons app to Google App Engine Boston Python meetup - 6/18/08 Nate Aune www.jazkarta.com www.nateaune.com 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. Tubemogul.com 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 http://myspace.com/poludaktulosorchestra 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 Upcoming.org • version 0.3 @ DevHouseBoston4 2008 • rewrite as Pylons app deployed to GAE 7
  • 8. Bootstrap with the appenginemonkey $ svn co http://appengine-monkey.googlecode.com/svn/trunk ape-monkey $ cd ape-monkey $ python2.5 appengine-boot.py --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 setup.py 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/dev_appserver.py ~/gae/gigblastr/ • Visit http://localhost:8080/ 9
  • 10. Edit the routes • In GigBlastr/config/routing.py 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/hello.py 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/hello.py import eventful def evtful(self): api = eventful.API('xxxxxxxxxxxxx') events = api.call('/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/appcfg.py 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 _speedups.py and _speedups.so 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 paste-deploy.py: ## 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 http://code.google.com/appengine/ • Pylons http://pylonshq.com • Instructions for Pylons on GAE http://code.google.com/p/appengine-monkey/wiki/Pylons • DevHouseBoston http://devhouseboston.org 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