Deploying a Pylons app to Google App Engine

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

1 comments

Comments 1 - 1 of 1 previous next Post a comment

Post a comment
Embed Video
Edit your comment Cancel

1 Favorite

Deploying a Pylons app to Google App Engine - Presentation 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 \"I just started using Pylons last week.\" 2
  3. Disclaimer #2 \"I just started using Google App Engine last week.\" 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 \"Many- Fingered Orchestra\") 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 \"%s at %s\" % (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 \"/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__.py\", line 113, in <module> from encoder import JSONEncoder File \"/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.py\", line 6, in <module> from simplejson import _speedups File \"/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.py\", line 7, in <module> __bootstrap__() File \"/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.py\", 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

+ Jazkarta, Inc.Jazkarta, Inc., 2 years ago

custom

5751 views, 1 favs, 2 embeds more stats

A presentation at the Boston Python Users Group dem more

More info about this document

© All Rights Reserved

Go to text version

  • Total Views 5751
    • 5460 on SlideShare
    • 291 from embeds
  • Comments 1
  • Favorites 1
  • Downloads 41
Most viewed embeds
  • 289 views on http://nateaune.com
  • 2 views on http://www.python.rk.edu.pl

more

All embeds
  • 289 views on http://nateaune.com
  • 2 views on http://www.python.rk.edu.pl

less

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

Cancel
File a copyright complaint
Having problems? Go to our helpdesk?

Categories