Showing posts with label GAE. Show all posts
Showing posts with label GAE. Show all posts

Tuesday, 29 January 2013

Install Google App Engine on Ubuntu 12.10

Google App Engine  is currently on version 1.7.4 and Ubuntu has recently released Ubuntu 12.10 (Quantal Quetzal). Quantal Quetzal comes with Python 2.7 installed, and App Engine has been providing that version of Python as an option since February 2012. So if you are starting a new App Engine project, it's probably a good time to move to Python 2.7.

I'll explain briefly how you start a new project and there's a nice clean copy of the code at the bottom that you can cut and paste.

Let's get the show on the road. Choose a name for the project and create and switch to a virtual environment:

PROJ=gae_project
mkvirtualenv ${PROJ}
cdvirtualenv

Note that note that "--no-site-packages" and "--distribute" are now the defaults for mkvirtualenv. You don't even need to use "--python=python2.7" on Ubuntu 12.10.

Now we need to know what the latest version of App Engine is, but as of writing it's 1.7.4:

GAE=1.7.4
wget -O /tmp/gae.zip http://googleappengine.googlecode.com/files/google_appengine_${GAE}.zip
unzip /tmp/gae.zip

Now let's create an App Engine app. The app will need a name that has been created in the App Engine Console:

GAE_APP_NAME=dummy
mkdir -p gae_app/static

Now create the app.yaml file:

echo """application: ${GAE_APP_NAME}
version: development
runtime: python27
api_version: 1
threadsafe: true

default_expiration: 7d

handlers:
- url: /static
  static_dir: static
- url: .*
  script: wsgi_app.app
""" > gae_app/app.yaml

And finally the app itself:

echo """import webapp2

class MainPage(webapp2.RequestHandler):
  def get(self):
      self.response.headers['Content-Type'] = 'text/plain'
      self.response.out.write('Please replace me with a decent WSGI App Framework such as Flask')

app = webapp2.WSGIApplication([('/', MainPage)],
                              debug=True)
""" > gae_app/wsgi_app.py


And finally to run the development server:

python ./google_appengine/dev_appserver.py gae_app/

I hope that this has all been of some help to you. Did I miss anything? Please comment below.

Friday, 4 May 2012

Install Google App Engine on Ubuntu 12.04

If you want to use Google App Engine on Ubuntu there are a couple of things to note. Firstly GAE has recently moved to version 1.6.5 and secondly Ubuntu has recently released Ubuntu 12.04 (Precise Pangolin). Precise Pangolin is a Long Term Support (LTS) version of Ubuntu to come with Python 2.7 installed, and App Engine has been providing it as an option since February 2012. So if you are starting a new App Engine project, it's probably a good time to move to Python 2.7.

I'll explain briefly how you start a new project and there's a nice clean copy of the code at the bottom that you can cut and paste.

Let's get the show on the road. Choose a name for the project and create and switch to a virtual environment:

PROJ=py27_gae_project
mkvirtualenv ${PROJ}
cdvirtualenv

Note that note that "--no-site-packages" and "--distribute" are now the defaults for mkvirtualenv. You don't even need to use "--python=python2.7" on Ubuntu 12.04.

Now we need to know what the latest version of App Engine is, but as of writing it's 1.6.5:

GAE=1.6.5
wget -O /tmp/gae.zip http://googleappengine.googlecode.com/files/google_appengine_${GAE}.zip
unzip /tmp/gae.zip

Now let's create an App Engine app. The app will need a name that has been created in the App Engine Console:

GAE_APP_NAME=dummy
mkdir -p gae_app/static

Now create the app.yaml file:

echo """application: ${GAE_APP_NAME}
version: development
runtime: python27
api_version: 1
threadsafe: true

default_expiration: 7d

handlers:
- url: /static
  static_dir: static
- url: .*
  script: wsgi_app.app
""" > gae_app/app.yaml

And finally the app itself:

echo """import webapp2

class MainPage(webapp2.RequestHandler):
  def get(self):
      self.response.headers['Content-Type'] = 'text/plain'
      self.response.out.write('Please replace me with a decent WSGI App Framework such as Flask')

app = webapp2.WSGIApplication([('/', MainPage)],
                              debug=True)
""" > gae_app/wsgi_app.py


And finally to run the development server:

python ./google_appengine/dev_appserver.py gae_app/

I hope that this has all been of some help to you. Did I miss anything? Please comment below.

Sunday, 6 November 2011

Google App Engine Python2.5 Development in Ubuntu 11.10

How to set up a development environment for Google App Engine, Python2.5 in Ubuntu 11.10.
Firstly, sorry if the code below is badly formatted, but there's a clearer copy of the code at the bottom.

Python2.5 isn't in the Ubuntu 11.10 sources by default so in a console:

sudo add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update

and install python2.5 and some other stuff:
sudo apt-get install python2.5 python-virtualenv virtualenvwrapper python-pip

Next for project 'oinkyoinker':
export CURRENT=oinkyoinker
mkvirtualenv --no-site-packages --distribute --python python2.5 ${CURRENT}
workon ${CURRENT}
cdvirtualenv
pip install fabric yolk ipython readline

Now download GAE and fix the path:
wget -O /tmp/gae.zip http://googleappengine.googlecode.com/files/google_appengine_1.5.5.zip
unzip /tmp/gae.zip
echo "../../../google_appengine" > lib/python2.5/site-packages/gae.pth
and create a simple file server app:
mkdir -p application/static

echo """application: oinkyoinker
version: 1
runtime: python
api_version: 1
default_expiration: "7d"
handlers:
- url: /
  static_dir: static
""" > application/app.yaml
and run it:
./google_appengine/dev_appserver.py application/
Hope this helped you too.

Tuesday, 14 June 2011

My Top Ten Python Web Frameworks

An updated version of this article can be found here.

I have recently revisited all of the Python Web Frameworks that I know of and re-evaluated them for use in a new project.

I did this first two or three years years ago and so I imagine I will be biased by the decisions that I made then, so I think it's only fair to say that I started using Django because of it's fantastic documentation and I suppose the helper scripts which help the beginner along. However, all that Convention over configuration stuff can be too much for me sometimes.

I then moved onto Tipfy because it slotted in so easily to Google App Engine which I was using a lot at the time  and the Django framework itself was starting to be more of a hindrance than a help.

One day however I stumbled upon Bottle which was a revelation. Being a micro framework it's explicit. That is if you want to use something, you make up your mind to do so; it's not some cleverness built into the framework over which you have no obvious control. If you want to know how it works, then read the code!

Finally I came to Flask, another micro framework, because I like the way it is based on Werkzeug and other well trusted libraries which gives me a some peace of mind that it is supportable, and secondly because it is also explicit like Bottle.

All that being said, here's my top ten:

  1. Flask - small, fast, easy to learn and built on reassuringly supported libraries.
  2. Bottle - small, fast and a great tool for learning.
  3. Tipfy - built for GAE, easy to pick up and well supported.
  4. Django - contains most of what you will ever need to build a website, well documented, but starting to bulge at the wasteline.
  5. Pyramid - the successor to Pylons, this one has great docs and great ideas. It is a framework, but you can unpick the bits you don't like.
  6. CubicWeb - like Django, Convention over configuration, but nice in some ways. 
  7. GAE framework - Simple, built for GAE, and well documented.
  8. Web2py - I hate it, but love it. All that framework kinda helps, kinda hinders. Give it a little time and you can definitely pull a website together, it depends on your personality whether or not you go mad first though.
  9. Nagare - I admit I haven't built a full system with this one, but I have a feeling I will be soon. I'd rather it was a wee bit more mature though, but the libraries/concepts it's built on is all good stuff.
  10. Weblayer - Another micro framework. Some good ideas here, but could do with a little love, If you are a developer looking for a worthwhile project, you should consider lending a hand.

[Please note I am currently updating this article here]


For more information, please read: