Python Webframework Confusion - python

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

Related

How do I create a web application using Core Python without a framework?

I want to build an web application using python as a backend so, as I did not learned any of the web frameworks that are available for python I want to know is there any way to create backend for an app without frameworks.
While there is a discussion in the comments about the utility of frameworks, I am trying to answer the question at its face value.
WSGI
Python frameworks like Flask and Django both at the end are WSGI applications. WSGI (Web Service Gateway Interface) is a PEP specification which defines how the server and client must communicate. If I were to start from scratch, I would probably start with learning about WSGI and even try implementing a little ping-pong server with it. The read the docs page here https://wsgi.readthedocs.io/en/latest/learn.html lists a number of pages to learn about it.
Werkzeug
Once the WSGI specs are understood then one can attempt building a simple library that will wrap the core concepts into reusable functions and modules for easily writing an application. Here Werkzeug can be a good guide to make one understand the different aspects. https://www.palletsprojects.com/p/werkzeug/
Your own application
Based on the understanding of the WSGI spec and the Werkzueg library you can go on to write your applications either from scratch, or write a library like werkzueg yourself and then use it to write an application.
Finally reimplement the same app in Flask or Django to see what frameworks offer.
If it's something small for internal use you can use
https://docs.python.org/3/library/http.server.html

Need Django GUI IDE

I am new with Django. I need to quickly develop a sophisticated GUI for a Django project. My underlying database is resource description framework (RDF). Is there any Eclipse IDE available for quick Django GUI development? Or is there any other GUI development tool (provides widgets) available for Django based project?
JetBrains has a Product for Python developers with Django support.
Its not for free but you can try it for 30 days.
https://www.jetbrains.com/pycharm/
Django is a web framework. It doesn't have a GUI. Though there are many IDEs that support Django template syntax, none of them will provide any kind of GUI functionality.
As far as IDEs go, Jetbrains is good, Eclipse has pretty decent python support, though I'm a big fan of sublime texts smart simplicity.
As for GUI stuff, perhaps rethink a little here. Django is a web framework that deals best with transactional interaction. It fires you a web page, you fire it a response. The system isn't really a good fit to GUI stuff. Thats not to say it can't play a part. Instead consider splitting it into a client/server product. Both TastyPie and Django Rest Framework are good options for building a RESTful API that can be interrogated by a remote client. You can then build the client using either one of the visual studio suites, or delphi, or if your looking to stay within the python mothership, perhaps PyQT/PySide (Which include a visual form designer) would be more up your alley. I guess you could build djangos ORM into an app (Although personally I'd use SQLAlchemy for that as its more decoupled than djangos ORM), but I'd warn that direct network access to databases isn't generally held to be wise for obvious security reasons, and you need to have a have a hard think about the threading implications if your gui toolkit is multithreaded, because Djangos ORM isn't built with the assumption it'll need to deal with multiple threads over single objects. My 0.02c is use Django to build an API and PyQT (or whateer your comfortable with) for the front end.
GUI is a term more for desktops, frontend is for web, for more see https://en.wikipedia.org/wiki/Graphical_user_interface.
Try any HTML5 WISWYG editor to make frontend (probably responsive) design.
More no this look in https://softwareengineering.stackexchange.com/questions/148489/how-to-develop-front-end-ui-for-my-django-website

Amazon AWS web framework for Python

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.

Django + GAE (Google App Engine) : most convenient path for a beginner?

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.

What Python/IronPython web development framework work on the Microsoft technology stack?

I started learning Python using the IronPython implementation. I'd like to do some web development now. I'm looking for a python web development framework that works on the Microsoft technology stack (IIS + MS SQL Server). Django looks like an interesting framework but based on what I have read, getting it to work on the Microsoft technology stack seems very hard or not possible.
I want to lean a web framework that leverages python strengths, so ASP.NET is not an option here.
The reasons why I want to do Python on full Microsoft stack are:
We are a .Net shop and our production servers run the full Microsoft stack
With IronPython, I'll be able to interop with our product's existing .Net Libraries
Our existing database runs in SQL Server and I want to develop an app that queries that database
Deploying my Python projects to our server will not be allowed if I have to install another web server
Any recommendations?
Working with the full MS stack will be hard as not many FLOSS frameworks aim there. You'll have better luck with a WAMP (Windows/Apache/MySQL-PostgreSQL/Python) approach.
That being said, Django works on Windows, and even can be made to work under IIS by using PyISAPIe and MS SQL Server support.
TurboGears can also be installed on Windows, and has MS SQL Server support through its ORM backends.
Trying to use -AMP under Windows can be an exercise in masochism sometimes. It can be done, but using these frameworks under Linux/BSD is much much easier and enjoyable. You should definitely try it.
While perhaps not entirely mature, isapi-wsgi looks like a promising way to run the WSGI intermediate layer on IIS (I have no hands-on experience with it, but seems worth a try!). Once you have WSGI running just about any Python web framework, including Django, should run on top of it (my personal favorite is werkzeug, a non-framework of utilities on top of WSGI, but I realize it's probably a lower level of abstraction than most web developers prefer for typical web apps and websited).
django-mssql should let Django run fine on SQL Server and looks reasonably mature (again, no hands-on experience). If you prefer a more sophisticated obj-relational mapper, SQLalchemy claims to support MS-SQL "out of the box" with minor restrictions (e.g., no more than one IDENTITY column per table).
If you want to stick with IronPython, but can live with using SQLite instead of MS-Server, it should also be possible to use Django on IronPython with IIS.
Django does in theory run on Windows, but using Apache and MySQL. It's not possible (and certainly not recommended) to run it on IIS.
I know you totally didn't ask this, but I have to advise that if you really want to get into Python web development then looking into a Linux technology stack is definitely the recommended approach. :)

Categories

Resources