We are planning a web application to build on Google's App Engine platform.
Is it good to use the Django 1.1 framework to develop Google App Engine applications?
If not, could you please suggest me the best option available, which has good tutorials and learning resource?
Yes, Django 1.1 is well-supported on Google App Engine. You'll need to do your own installation thereof locally, to enable it in the GAE SDK -- but it's already there for you on the App Engine production servers, see the docs -- just do
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
from google.appengine.dist import use_library
use_library('django', '1.1')
Edit: Django is by far the leading web app framework for Python, and its popularity is surely well-deserved. However, personally, I use it only when I "have to" (mostly to get collaborators and make them comfy on a project's technology stack) -- maybe because what I tend to develop server-side are more "web services/apps" than "sites" (the UI part I'd rather leave to the browser, with Dojo, jQuery, or Google Closure!-), I find Django too "heavy" for my tastes. I'd rather have Werkzeug, or tipfy -- the latest and greatest super-light Wekzeug-based App Engine - specialized framework!-) -- I love e.g. tipfy's ability to use Jinja2 and/or Mako in lieu of Django's templates, the simple and flexible authentication and session schemes, and the debugger -- in addition to all the luscious, light-weight flexibility of Werkzeug and Webapp. But, hey, that's a very subjective opinion of mine!-)
Google has developed a 'helper' project to aid with Django integration:
http://code.google.com/p/google-app-engine-django/
Also, you might check out this video where Guido walks through it:
http://sites.google.com/site/io/rapid-development-with-python-django-and-google-app-engine
You should check out appenginepatch (http://code.google.com/p/app-engine-patch/) and django-nonrel (http://www.allbuttonspressed.com/projects/django-nonrel)
I'm using appenginepatch for my website (beta.fiddme.com) and its awesome (there's a full post on the technology stack we're using at http://www.developerzen.com/2009/10/29/building-an-iphone-application/)
You might also want to take a look at Kay Framework. It's based on Django with middleware and such. It is exclusively geared towards App Engine and uses Werkzeug and Jinja2. I have fiddled with it and it all works. I've settled on the already mentioned Tipfy framework. Also comes with Jinja2 (and Mako, it's your choice), it's lightweight and easy to comprehend.
Related
I may be late to the party, but I've been playing around with Google App Engine.
My plan was to convert an existing open-source Django app to run on GAE.
I went through the O'reilly book, Programming Google App Engine to get the gist of GAE.
I'm ready to start diving in, but I'm curious as to the best way to approach it.
I Django-nonrel currently the best option to use?
My Google-fu isn't really turning up many examples of people converting a Django app to run on GAE. The few that I have found seem to date to 2010 or earlier. Is this because people are not finding it worthwhile to use GAE with Django?
What has been your experience porting Django apps to GAE?
Google App Engine now supports SQL databases so you can have a regular django app on GAE. Here is the official documentation, and here is a nice tutorial from another related question.
I have personally run django sql (and nonrel) apps on gae and they have been fine.
Which of these would you pick for a B2B app (targeting small/med-small businesses) built on GAE with python:
Google Accounts
Custom Users with Django
Custom Users with Web2Py
I'm very tempted to go the Google Accounts route as it's very well integrated into GAE and takes care of everything from user creation to session authentication, and even takes care of forgotten passwords. However, I'm sure there are significant drawbacks to this, including usability, but if you are starting from scratch, which approach would you pick and why?
I started with Google account, added all OpenID and quickly found that the only accounts people use for my site are google and facebook accounts. So now I only have login with google and login with facebook. But I'm going to add my own accounts and I'm doing it with webapp2 instead of django and instead of web2py. I tried web2py but webapp2 and its auth model seem much better and not like with web2py a lot of unnecessary code that is not for app engine.
Try this and its auth model (there is example code from http://code.google.com/p/webapp-improved/issues/detail?id=20) and I hope it will work for you.
Google Accounts forces users to have Google Apps or Gmail accounts. Some customers might not like this.
Rolling your own is an (unnecessary) burden: you have to have sign up process (with captcha and/or 3rd party email confirmation), keep all user records, handle the security, etc..
I'd suggest you go with OpenID: http://code.google.com/appengine/docs/python/users/overview.html#Authentication_Options
Why both Create Django user from Google users. you will be able to adapt your system user with other system next
I've understood that question was only on authentication after I've written this so most of things here are offtopic, but I just wanted to demotivate on using full-stack solutions like django or web2py in appengine.
I can tell you something about django because I've used it for over a year and I do like it for certain types of websites. It was first framework which I've tried to use on appengine and I've dropped it after two weeks.
These are things in django which doesn't work or make no sense in appengine:
django models and orm: designed for sql; appengine sdk has its own models.
django admin site: is designed for sql databases, doesn't work on appengine
auto-forms from models: designed for django models
django management commands: none of commands which come with django is useful when working with appengine SDK.
django development server: appengine sdk has its own development server, django's one does not work.
django "plugable apps" architecture: at least in my practice it was useless on appengine.
static files collector: great tool to collect static files from various reusable applications into one folder, only if you have many reusable applications.
There exists django-nonrel project which says it can run django with admin site on appengine. It can, with half of things working and a lot of bugs. You spend more time trying to fix what does not work than building things.
What might be useful from django framework:
django forms: can be exchanged for a better library WTForms
django url routing: can use Werkzeug instead
django request/response objects and HTTP exceptions: can use Werkzeug instead
django pretty-printing exceptions: Werkzeug does it better, it adds a web debugger.
django i18n and localization: can be changed with babel
django templates: jinja2 is similar and a lot faster, which is important because appengine is an expensive platform. ctypes module is required to debug errors in jinja templates, however ctypes is forbidden on appengine, but on development server it does work, for debugging you don't need more.
Actually Jinja2, Werkzeug, WTForms and babel are so cool, that there exists projects for each of them which integrates them with django.
I know two frameworks which use these libraries:
kay-framework: made for appengine, a bit outdated, but a great example how you can use Jinja2, babel and Werkzeug on appengine.
flask from Armin Ronacher, the man behind Werkzeug and Jinja2.
I've not used web2py, however since it is also a full-stack framework like django is, I think it will be as bad as django is. Full-stack solutions simply do not fit in this different environment. Simple libraries fit in any environment.
I am looking for a simple python web framework which runs both as standalone and on Appengine.
I would like to write the app in such a way that i can switch between standalone and Appengine based on the deployment configuration. Standalone will be using RDBMS.
When i checked web.py looked simple and promising. I have the following questions:
Does web.py work well on Appengine?
Is there any major known gotchas?
Can you share your experience with using web.py on Appengine?
Any suggestions to achieve the above mentioned goal is appreciated.
Does web.py work well on Appengine?
Yes it does work pretty well, it's compact and very easy to use.
Is there any major known gotchas?
Web.py does not offer any Data Abstraction Layer compatible with GAE; that means that in order to switch from a RDBMS to a NoSQL database, you have to create by yourself a layer above both the web.db database API and the Google App Engine datastore API.
Can you share your experience with using web.py on Appengine?
I have deployed a couple of simple applications with web.py on top of GAE and other several pet projects with Sqlite as database; here a mini review.
Any suggestions to achieve the above mentioned goal is appreciated.
If the switch from Appengine to RDBMS is your primary concern, have a look to web2py.
Although with some limitations, to the best of my knowledge is the only one Python web framework GAE friendly that offers a DAL above the App Engine Datastore and other several RDBMS solutions.
Switching from one db to another is just a matter of initializing the DAL with the proper connection string:
db = DAL('sqlite://storage.db')
db = DAL('mysql://username:password#localhost/test')
db = DAL('gae')
No webapp framework on its own is going to be able to do this - the App Engine environment consists of a lot more than just a database interface and a CGI environment. Even if it could, any DAL that supports both the datastore and a relational DB is likely to sacrifice most of the flexibility of both in pursuit of that.
Your best option, if you want to take advantage of more than just the datastore, is to write your app for App Engine, and use AppScale or TyphoonAE to run your app outside the App Engine environment.
Consider using webapp2. It is similar to web.py, provides basically the same featureset, and runs outside of App Engine out-of-the-box. Besides, you get stellar compatibility with App Engine SDK and libraries (I explain it better here).
You'd only need to add a relational database library. But this is an easy choice: SQLAlqchemy is pretty much the standard in Python land, with lots of documentation and a thriving community.
I would also suggest web2py. Great framework, great community, plays out-of-the-box outside of AppEngine. It also supports a lot of databases (SQLite, PostgreSQL, MySQL, MSSQL, FireBird, Oracle, IBM DB2, Informix, Ingres, and Google App Engine).
On top of that, it's trivial to install it on Linux, Windows, Mac.
Webpy.org - Who uses web.py?
"[web.py inspired the] web framework
we use at FriendFeed [and] the webapp
framework that ships with App
Engine..."
— Brett Taylor,
co-founder of FriendFeed and original
tech lead on Google App Engine
Google App Engine Getting Started for Python
HTML embedded in code is messy and
difficult to maintain. It's better to
use a templating system... ...For your
convenience, the webapp module
includes Django's templating engine
Questions:
What are the differences between webapp and webpy?
Is it worth the trouble to bundle webpy when Appengine already offers webapp?
What I know:
1. Web.py has a templating language of it's own(it looks easier than Django's)
2. Currently, the only reason for which I am thinking about using web.py is to avoid using(and learning) Django for templating on appengine.
3. The quotes at the head of this question
4. I have been through related questions and through the webapp documentation on Google.
5. I have noticed that stackprinter uses web.py and is hosted on appengine.
web.py experience:
I started to use web.py three years ago when I decided to learn some Python web frameworks.
The first thing I loved of web.py was its simplicity; I was searching for an essential microframework without all the batteries that you can find in other bigger projects like Django or Web2py for example.
So I developed a couple of projects (deployed with fastcgi) and learned all of the web.py library features, Templetor included.
Then I discovered Google App Engine and started to use Webapp; it was a boring process because instead of using python (like Templetor or Mako), it forces you to learn a new templating syntax that it is very restrictive by default.
While Developing StackPrinter I found that Google App Engine was supported by web.py so I removed Sqlite, made some minor tweaks and started to use GAE datastore.
Web.py was my first love in term of Python web frameworks and it's fair to say that I'm a little biased to talk about it.
I'm sticking with web.py for my pet-project on GAE because I'm fluent with it and templetor is lightning fast.
I like the fact that I can use Python for templating and the easy way to share some data or functions globally to the views, I like also the rich toolset of utilities for encoding, markdown and so on.
Webapp vs web.py:
I think it's not fair to compare them because Webapp is a simple framework that just provides the minimum easy tools to get started; many features are missing like I18n, validation, processors or even the basic cookies handling.
Check Webapp-improved for something better.
My recommendation:
If your focus is mainly on developing for Google App Engine, I would recommend you to go with some framework made specifically for GAE like Tipfy.
If you are searching for a pythonic web framework to play with on your side-projects, web.py is a good project to study and to follow.
Differences between webapp and web.py
The primary differences (IMHO) are that:
The webapp framework was designed specifically for Google App Engine (GAE). The web.py framework was not designed specifically for GAE.
"The webapp Framework is the default tool set for building web applications [in Google App Engine] but not the only one." (Source: Developing with Google App Engine by Eugene Ciurana)
They use different templating languages—web.py uses its own, whereas webapp's templating language is based on Django.
Other Python frameworks for GAE
Other Python frameworks for GAE—neither of which use the Django templating language—include:
Flask — "A microframework for Python based on Werkzeug, Jinja 2 and good intentions."
tipfy — "A small but powerful framework made specifically for Google App Engine. It is a lot like webapp, but offers a bunch of features and goodies that webapp misses: i18n, sessions, own authentication, flash messages and more. Everything in a modular, lightweight way, tuned for App Engine."
Is it worth the trouble to bundle webpy when Appengine already offers webapp?
Personally, I think that it is worthwhile to use something besides webapp. However, I would lean toward Flask or tipfy.
Alex Martelli endorses tipfy in his answer to the SO question Google App Engine - Secure Cookies. The main takeaway for me from Alex's answer is that tipfy is:
Designed to work with GAE
Lightweight
Contains built-in functionality that you often want
They're very similar, it just happens that webapp is more tailored to GAE than web.py. webapp is very small and is definitely optimized for writing for App Engine, so if that's your cup of tea, you should use it. You did say you didn't want to use Django's template system (I don't know why, it's pretty easy), which is what webapp comes with by default. The template system can be changed, but I recommend you give the Django engine a try.
That said, if you don't like it it's not terribly hard to set up with a new framework (basically anything WSGI compliant ought to work). If you want to use web.py, by all means, set it up, but you may have to do a little searching on how to set it up and configure everything to work.
Basically I have a webfaction space (assume for the purposes of this question that its free).
I am trying to learn python by created some simple web applications on Google App Engine using Eclipse + Pydev for development.
So far I have some basic functionality working in App Engine, though I have had some frustration with some library imports not working and whatnot (this may not be app engine specific).
So, is it worth it to switch now to webfaction, and leave GAE?
I am trying to learn python by created
some simple web applications on Google
App Engine using Eclipse + Pydev for
development.
This seems reasonable. Nothing wrong with using GAE, Eclipse, and Pydev to learn to do Python web dev.
So far I have some basic functionality
working in App Engine, though I have
had some frustration with some library
imports not working and whatnot (this
may not be app engine specific).
So, is it worth it to switch now to
webfaction, and leave GAE?
You haven't provided much of a reason to leave GAE now that you've started there. I think that "some frustration" is normal for learning on any platform.
Beyond that I think this could descend into a general GAE good for learning vs. GAE bad for learning discussion.
So let me get that started...
Since GAE is a 'Platform as a service' (PaaS) it makes deployment and maintenance very simple. You can get right to coding and not worry about the platform. As well, this platform provides some services, such as e-mail and authentication that make those tasks very easy. For example, on first pass you can just make use of their authentication API (supports Google and now openID authentication I think) and leave more complicated authentication options for later.
On the other hand, this platform is kinda' non-standard. The datastore is the main issue and that affects Django. That's a pain because it means that the Django running on GAE is slightly different then the standard Django and the Django docs that you are reading might not apply for GAE, etc.
Here is a current thread about getting started with Django on GAE (which addresses the datastore issue):
http://groups.google.com/group/google-appengine-python/browse_thread/thread/8d1c945d27b6305f
Hope that helps.