Some background info first:
Goal: a medium-level complexity web app that I will need to maintain and possibly extend for a few years.
Experience: good knowledge of python, some experience of MVC frameworks (in PHP).
Desiderata: using django and google app engine.
I read extensively about the compatibility issues between GAE and Django, and I am aware of the GAE patch, the norel project, and other similar pieces of code. I have also understood that the SDK provides some of the features of django "out of the box".
Yet, given that I have no previous experience with neither Django nor GAE, I am unable to evaluate to which extent using a patched version of Django will strip away important features, or how far the framework provided in the SDK is compatible with Django. So I am rather confused on what would be the best way to proceed in my situation:
Should I simply use a patched version of Django as the differences with the original Django are so minor that I would hardly notice them?
Should I write my app completely in "regular django" and try to port it to GAE only afterwards, when I will have got a grasp on Django internals and philosophy?
Should I write my app using the framework provided with the SDK and port it to django only afterwards?
Should I... ?
Thank you in advance for your time and advice.
I'm not sure if Django is a good fit for you. Django is a great framework for standalone applications because it provides a full stack solution: an ORM, authentication system and an admin interface, to name a few. You won't be able to use any of these on App Engine. Furthermore, many of the code samples are geared towards using the built in Webapp framework - you can very easily set cache expiration and authentication settings in app.yaml for configuration.
I see one of two paths for you:
Learn App Engine with Webapp. There's enough to learn about using the datastore and App Engine's services that'll keep you busy.
Learn Django off App Engine. You'll learn a lot about using Django's ORM, Admin goodies, URL routing, Forms and templates
By trying to learn both at the same time, you'll spend more time than you need learning the nuances of Django/GAE compatibility, time you could be spending either learning Django or GAE.
Related
I've done a lot of research for Google App engine. I ended up with webapp2. Now we realized that AWS has many advantages over GAE for our project.
I feel a little bit overwhelmed because there is so much information about AWS.
I ended up with the nosql dynamoDB solution.
Now I really love lightweight frameworks like webapp2 , its really simple and easy to use. It also don't hide post and get from you.
Now does it makes sense to use webapp2 for AWS ? Mabye there other frameworks that would fit better for our project.
(We want to go in a filehosting direction)
I mean there are literally 50 frameworks for python. And I didn't find a chart with pro/cons.
The last frameworks that I investigated are : web2py , pylon(now pyramids?) and tornado.
To be honest I am really confused.
So if I want to have a lightweight framework for AWS would you recommend me to stay with webapp2?
Resources:
Amazon AWS web framework for Python
Edit #1
Now it's a decision between tornado and webapp2. considering that I want to use dynamoDB.
Tornado is a fast non-blocking web server itself. It's easy to write simple apps in a few minutes, but it has nothing AFAIK like templates, views, etcetera. If you want to serve files it would be very quick to connect a tornado server together with boto (https://github.com/boto/boto) and use dynamoDB or S3.
On the other hand, pylons (now pyrmaid) and we2py are full web application frameworks with no web server. In fact, they come with a lightweight development server (at least pylons), but if you want to put up a site in AWS you should use something like nginx (http://nginx.org/), apache or some other wsgi server (http://wsgi.readthedocs.org/).
If you want to go for a lightweight framework and use python, I'd go for web2py, easy to configure and build apps. (A curious note: it used to be a single .py file) you can try it online: http://www.web2py.com/demo_admin/default/site
Regarding webapp2 I've never used it, but I've heard it's similar to Appengine web framework. So if you're comfortable with it stay there.
Either direction, boto is the python interface for AWS so if you choose python, you'll have to check it out. It is actively mantained.
I like working with GAE environment as well as with its webapp framework. I am creating a web application using GAE environment. What I think about is how to create a version of my application that could run in another environment, like some other hosting or cloud service the easiest way. I know I will have to think about database storage alternative too and some other features that GAE gives and is not available on another platform out of the box. But now I wonder just about webapp framework. So, what can I use as alternative to this in GAE? May be some existing framework that is as much as possible close to GAE webapp? I know it is using webob, may be somebody has already implemented this alternative? Please give me some advice. Thanks!
The pre-release version of Tipfy is adding the ability to be used outside of App Engine.
Also, you might want to consider instead of finding a web framework that works in multiple environments, try out a way to run App Engine apps in other environments with something like AppScale, or TyphoonAE.
Have a look to web2py, in my opinion it's a great and well documented web framework and it offers a powerful Dal that allows your application to be portable among different types of database, GAE datastore included *.
* with some limitation explained here
I would look at Pyramid. Running Pyramid on Google App Engine
Like you mentioned, SQLAlchemy doesn't work on GAE and you won't be able to use the same data storage routines. Depending on what you are doing, you could design your application so that most everything else would be interchangeable.
Another option would be Django-nonrel. It's a version of Django that will work on app engine and is designed to make it easy to port your code from app engine to other platforms.
Running Pure Django Projects on Google App Engine
I've written a couple GAE applications, and have come to feel that Django Nonrel is a little too heavy for my tastes. I really like the ease-of-use of Flask, and I'd expect you'd feel the same way — especially for simple apps.
Here's one GAE Flask skeleton.
Here's another.
You could also check out tipfy.
There are a few projects thats are working on replicating the GAE environment:
Typhoon AE
App Scale
I have not personally used either of these but I think that would be the best place to get started.
You should check out Series about using Google App Engine with some Python web frameworks by franciscosouza
I dealt with GAE before and I like simplicity of its webapp. Now I am trying to learn how to work with Amazon EC2. My question - where do I start to make a simple web application that I will be able to access form browser? I suppose I should use WSGI for this purpose. I don't want to use Django as I want to keep the application small and lightweight without unnecessary features. What can you recommend? Thanks.
AWS and GAE are very different. GAE very strictly defines what you can and can't do in terms of development environment. AWS gives you a server to do whatever you want with.
GAE is good when you don't want to have to figure out how all the pieces fit together to scale well. AWS is good when you need flexibility to do whatever you want in your environment.
So to answer your question -- you can use any framework / environment you like.
Personally, I like Django/Pinax for anything requiring a user system. You want a lighter weight system, I've heard good things about Pylons.
Here's a listing of a few others:
http://wiki.python.org/moin/WebFrameworks
Since we're talking AWS, it doesn't have to be python. Ruby on Rails is great.
As already mentioned, you have a lot more flexibility with Amazon than with GAE. If you want to stick with Python and would like to be able to access your app through your browser, you might consider web2py, which enables you to edit and manage your apps through a web-based IDE and admin interface (see demo).
web2py was designed for ease of use and developer productivity, so it's very easy to learn and get going quickly, and you can get a lot done with very little code. Although it's easy to do simple (and even not-so-simple) things quickly and easily, if your app gets more complex, web2py can handle that too, as it is a well-integrated full-stack framework with lots of built-in functionality, including a database abstraction layer, form handling and validation, access control, web services, and easy Ajax integration.
web2py runs on GAE out of the box, and web2py apps are portable from GAE to other platforms without requiring any code changes. However, if you're looking for a simple, scalable cloud hosting option with more flexibility than GAE, you might take a look at the new DotCloud (still in beta), which actually runs on EC2. There's a demo web2py app running there now, and a tutorial explaining the simple deployment process.
If you have any questions about web2py, you'll get lots of help from the friendly and responsive mailing list. I know some of the users have hosted web2py apps on EC2. For example, this demo Q&A site powered by web2py is hosted on EC2.
I am about to start ramping up on Django and develop a web app that I want to deploy on Google App Engine. I learn that Google has Django 0.96 already installed on the APP engine, but the latest "official" version of Django I see is at 1.2.3 and its a bit of an effort to install it there.
I am curious which version of Django is most widely used.
So, can you please guide me on which Django version I should ramp on and deploy based on the following criterion
Stability and suitability for production release
Availability for applications (or plugins) and which version is most supported by the community
Thanks a lot!
Most people are currently using Django 1.2. You should not use or learn Django .96 - it's VERY old, and learning to use it won't prepare you for any non-app-engine Django work since things have changed significantly since then.
Django on App Engine is something of a pain, since you lose a lot of the ORM, which is a really nice reason to be working with Django. You also lose the ability to simply drop-in plugins and reusable apps that use any of the Django ORM. Anything with a models.py won't work.
Take a look at google-app-engine-django for help getting a more recent version running.
http://code.google.com/p/google-app-engine-django/
There is work to integrate the GAE storage engine into Django, and several projects have variously working implementations, but I wouldn't expect really good ORM support for a while yet - 1.3 (which is still several months from release) will include hooks that make it easier to write NoSQL backends, but Django probably won't ship with one.
While there are security releases for old versions of Django, you should really be developing using the latest stable version. Major releases of Django have a very strong backwards compatibility promise, so going from 1.2 to 1.3 when it comes out will be pretty seamless.
I strongly encourage you to think long and hard about what precisely App Engine offers your specific application before spending a lot of energy getting things working there. You lose application portability, scaling is still hard, and you don't save money if your application gets popular. App Engine is not a forgiving introductory platform.
For more conversation on this topic, take a look at this question:
Why use Django on Google App Engine?
particularly my answer there and the comments on it.
app engine permits you to use other versions of django out of the box, with only a little pain, using google.appengine.dist.use_library. essentially, your main.py (the module specified by app.yaml to handle urls) should look like this:
import wsgiref.handlers
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
from google.appengine.dist import use_library # important bit
use_library('django', '1.1')
import django.core.handlers.wsgi
def main():
application = django.core.handlers.wsgi.WSGIHandler()
# Run the WSGI CGI handler with that application.
webapp.util.run_wsgi_app(application)
if __name__ == '__main__':
main()
Another thing to consider is how you install. I'd be sure to install django from SVN, because it makes updating it MUCH easier.
I have been using the dev version for a while on my site, and haven't encountered a single bug yet, aside from one that affected the admin site in a minor way (which a svn up fixed).
I don't have a feel for whether people are using 1.2 or dev, but in my experience, dev is perfectly suitable. Any major errors that you may have in the code will get fixed very quickly, and svn up will get you to the latest code on the off chance that you get a revision with a major bug.
Could someone please explain to me how the current python webframworks fit together?
The three I've heard of are CherryPy, TurboGears and Pylons. However I'm confused because TurboGears seems to use CherryPy as the 'Controller' (although isn't CherryPy a framework in in it's own right?), and TurbGears 2 is going to be built on top of Pylons (which I thought did the same thing?).
There are more to it ofcourse.
Here's a comprehensive list and details!
Web Frameworks for Python
Extract from above link:
Popular Full-Stack Frameworks
A web application may use a
combination of a base HTTP application
server, a storage mechanism such as a
database, a template engine, a request
dispatcher, an authentication module
and an AJAX toolkit. These can be
individual components or be provided
together in a high-level framework.
These are the most popular high-level
frameworks. Many of them include
components listed on the WebComponents
page.
Django (1.0 Released 2008-09-03) a
high-level Python Web framework that
encourages rapid development and
clean, pragmatic design
Pylons (0.9.6.2 Released 2008-05-28) a
lightweight Web framework emphasizing
flexibility and rapid development. It
combines the very best ideas from the
worlds of Ruby, Python and Perl,
providing a structured but extremely
flexible Python Web framework. It's
also one of the first projects to
leverage the emerging WSGI standard,
which allows extensive re-use and
flexibility but only if you need it.
Out of the box, Pylons aims to make
Web development fast, flexible and
easy. Pylons is built on top of Paste
(see below).
TurboGears (1.0.4.4 Released
2008-03-07) the rapid Web development
megaframework you've been looking for.
Combines CherryPy, Kid, SQLObject and
MochiKit. After reviewing the website
check out: QuickStart Manual
web2py (currently version 1.43)
Everything in one package with no
dependencies. Development, deployment,
debugging, testing, database
administration and maintenance of
applications can be done via the
provided web interface. web2py has no
configuration files, requires no
installation, can run off a USB drive.
web2py uses Python for the Model, the
Views and the Controllers, has a
built-in ticketing system to manage
errors, an internationalization
engine, works with MySQL, PostgreSQL,
SQLite , Oracle, MSSQL and the Google
App Engine via an ORM abstraction
layer. web2py includes libraries to
handle HTML/XML, RSS, ATOM, CSV, RTF,
JSON, AJAX, XMLRPC, WIKI markup.
Production ready, capable of
upload/download of very large files,
and always backward compatible.
Grok (0.13 Released 2008-06-23) is
built on the existing Zope 3
libraries, but aims to provide an
easier learning curve and a more agile
development experience. It does this
by placing an emphasis on convention
over configuration and DRY (Don't
Repeat Yourself).
Zope (2.10.4 Released 2007-07-04,
3.3.1 Released 2007-01-14, Zope 3.4.0c1 Released 2008-01-31) Being the grandaddy of Python web frameworks,
Zope has grown into a family of
frameworks over the years. Zope 1 was
released in 1999. Zope 2 is both a web
framework and a general purpose
application server, today it is
primarily used by
ContentManagementSystems. Zope 3 is
both a standalone framework and a
collection of related libraries, which
are also included with newer releases
of Zope 2. All of the Zope frameworks
include the ZODB, an object database
for Python.
Give a try to web2py. It is point and click (you do not even need to install Python, comes with it). You develop using a web interface and you can deploy almost everywhere, including iPhone, Oracle and Google App Engine. Before trying web2py, try install some of the other Python frameworks, you will appreciate it even more.
CherryPy is not a full-stack web framework (like Django for example), in fact it isn't a web framework but a HTTP framework. Writing a web application using CherryPy is much like writing a regular object-oriented application in Python.
Also, CherryPy has it's own production-ready WSGI web server, which can be also used for applications written using other frameworks, hence the confusion surrounding CherryPy as a framework.
If you are looking for a start-to-finish solution then it's worth mentioning that the leader of the pack in that space is Django
Have you tried FastAPI.
It's a is a modern, fast (high-performance), web framework for building APIs with Python 3.6+ based on standard Python type hints.
Pretty easy to learn, quite powerful and lightweight.
https://fastapi.tiangolo.com/
I have been using for my application and it seems to be similar to Flask, but quite robust.
from fastapi import FastAPI
app = FastAPI()
#app.get("/")
def read_root():
return {"Hello": "World"}
Some Video Tutorials can be found here
You can also find a lot of help materials from here