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.
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.
I don’t want to burden you all with the details, but basically I’m a 2nd year compsci student with no Web dev experience.
Basically I want to create a small “web app” that takes in input from a html form, have a python script perform some calculations, and re-display those results in your browser.
As of right now, I have the form and script built. However, when I try to test the form, instead of running the script, my browser tries to download it. To my understanding, this is a cgi script problem, and that I must create a web server in order to test this script.
And heres were I’m stuck. I know little to nothing about web servers and how to set them up. On top of that I’ve heard that GCI scripting is a thing of the past, and requires major overhead in order to run properly.
This leads to my questions. How do I go about completing my app and testing my cgi script? Do I install apache and mess around with it or should I be looking into something like google app engine? Are there other ways to complete this task without cgi scripts? Where do frameworks like Django fit into this?
Django, while being nice, all-encompassing and well-supported, is sometimes too much for a small web application. Django wants you to play by its rules from the beginning, you'll have to avoid things like the database and admin panels if you don't need them. It's also easier, with Django, to follow its project layout, even when it's too complex for a simple app.
The so-called micro frameworks might suit you better for your small app. They are built upon the opposite principle: use the bare minimum of features now, add more as you need them.
Flask is based on Werkzeug WSGI library and Jinja2 templating (the latter is switchable), is extensively documented (with notes concerning virtualenv and stuff) and well-suited for small and larger apps alike. It comes bundled with an auto-reloading dev server (no need for Apache on your dev machine) and Werkzeug-powered interactive debugger. There are extensions for things like HTML forms and database ORM.
Bottle is as small as a microframework can get, consisting of 1 (one) file, dev server included. Drop it into your project folder and start hacking. The built-in SimpleTemplate templating engine is switchable, but the dev server is flakier in comparison to Flask's. The documentation is less complete, and, in my opinion, the whole thing is less polished and convenient as Flask.
In both cases, you use dev server locally, and then deploy using WSGI, the server interface for Python web apps which both frameworks support. There are many ways to deploy a WSGI app, Apache mod_wsgi being one of the popular ones.
I'd totally go with Flask unless one dependency (Bottle) is better than three (Flask, Jinja2 and Werkzeug).
(There are many other frameworks as well, so wait for their users to come and tell about them. I'd suggest to avoid web.py: it works, but is full of magic, and is inelegant compared to Flask or Bottle.)
One way of getting to working webapp quickly is by first understanding, and then modifying, something like the App Engine "guestbook" example. This has the benefit that much of the otherwise necessary tedium of running a web server and setting up a database server (assuming you need persistence) is done for you. App Engine also provides a fairly flexible development environment. It's certainly not the only way to go, and I'll admit to bias in recommending it, but it's fairly low friction.
GCI scripting is hardly a thing of the past, though it's not what the cool kids are doing. CGI has the benefit, and the curse, of exposing more of the raw plumbing. It forces you to understand a lot about primitive (in the low-level sense) web architecture, but it's also a bit of a large bite to chew on if you have an immediate problem to solve that can solved by simpler means.
It appears most python web development seems to be done by frameworks these days. There are a couple reasons for this:
a plethora of mature tools. Django has built in user auth, built in database management, built in sessions, built in just about everything ORM which lets you seamlessly supports a couple databases.
Built in webservers. The larger python frameworks like django and pylons have built in webservers. Django has a very simple webserver python manage.py startserver (that simple) That makes it extremely easy to create and debug applications. It is single threaded so dropping a debugger into it is painless
Huge communities. If you have a django question it will be answered very quickly the so community is huge.
The django tutorial will introduce you to all the major aspects of development. It is only 4 pages and you will be able to get your app going a lot simpler than having to read, learn and fiddle with an apache setup.
https://docs.djangoproject.com/en/dev/intro/tutorial01/
Although django for right now might be overkill if your app is just going to be 1 form and a script to process it. Because of its seamless testing framework it is quite easy to grow any project. I have never used flask or bottle or the other microframeworks, but I would keep in mind where your project will be in the future.
As for where django fits into this, it is a full stack framework encompassing presentation (templates), data management (server orm), authentication, middleware, forms ... everything necessary to create a completely inclusive web application. Django and almost all other python frameworks implement the wsgi standard. It is an interface that allows for interoperation between webservers. http://en.wikipedia.org/wiki/Web_Server_Gateway_Interface it is pretty dry and you will never have to interface it directly. That is what these frameworks do under the hood.
Why setup and maintain your own webserver if you can use app engine. It has an excellent SDK for testing your code. Here is an example https://developers.google.com/appengine/docs/python/gettingstarted/handlingforms
And Django you will find here : https://developers.google.com/appengine/docs/python/gettingstarted/templates
I prefer to use Jinja for templating.
Django comes with its own server, but in your case i would recommend apache and mod_python since it seems to be a rather simple site you're building.
Setting up Apache is a breeze and a simple search on the web should give you all you need.
You can find more information on mod_python here read up a little bit on it and then google after a tutorial that fits your needs.
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.
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.
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.