I have a TurboGears application I'd like to run through Facebook, and am looking for an example TurboGears project using pyFacebook or minifb.py. pyFacebook is Django-centric, and I can probably figure it out, but this is, after all, the lazy web.
Why is pyFacebook django centric? Looks like it works perfectly fine with all kinds of WSGI apps or Python applications in general. No need to use Django.
pyFacebook is Django-centric because it includes a Django example. I did not intend to irk, but am merely looking for a TurboGears example using pyFacebook.
Related
I just started working at a place as a front end developer where I need to build Django templates. I never worked with these before, does anyone know where I can download a sample template so I can look through the code structure?
I won't be doing any application development using the Django framework, only taking the variables the developer gives me and incorporating the in the html/css templates I build.
There are lots of Open Source django apps that you could look at for inspiration. One example is Zinnia which is a blogging application - there are dozens of templates in this project, see this directory. There are many other open source django projects on http://github.com and http://bitbucket.org
You should also take a look at the official template documentation, there are lots of snippets there that are very useful.
Here's a nice little tutorial.
http://www.webmonkey.com/2010/02/use_templates_in_django/
Also, Check out the Django Docs.
http://docs.djangoproject.com/en/1.3/ref/templates/builtins/
I'm usually a PHP developer that has lots of experience with Drupal CMS & framework. And I realize Drupal is very mature, but I don't know much about the Python scene.
I've heard the following CMSs be mentioned:
Plone
Django (framework)
What other CMSs are there, and what do you think are some of the pros and cons? How mature are they? Is it even worth starting to use Python for general web development?
My vote is for Django CMS. Django itself is a development framework (but one that gives you a lot for free, including an excellent pluggable admin interface). DjangoCMS is an application that you can install into a Django application. I am using DjangoCMS and, as a Django user, I think it's perfect. I'm not what non-Django users would think. It's no Wordpress.
Here is a page which lists the Python based CMS. Zope based Plone is the very popular one and very mature too. Apart from that you, have customized solutions built using Django, like Django-CMS and also there are wiki like MoinMoin Engines. That page gives a lot of options for you.
Django is not a CMS; it's a web development framework.
That said, Django's roots come from newspaper-oriented CMS-like systems. Unsurprisingly, that makes Django a very good platform on which to create a CMS.
You can check the state of Django-based CMSs on Django-packages, which tracks the project metrics of many packages.
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.
I'm looking to write a small web app to utilise a dataset I already have stored in a MongoDB collection. I've been writing more Python than other languages lately and would like to broaden my repertoire and write a Python web app.
It seems however that most if not all of the current popular Python web development frameworks favour MySQL and others with no mention given to MongoDB.
I am aware that there are more than likely plugins written to allow Mongo be used with existing frameworks but so far have found little as to documentation that compares and contrasts them.
I was wondering what in people's experience is the Python web development framework with the best MongoDB support?
Many thanks in advance,
Patrick
I have not tried MongoKit although it has been around for a while and retains a good reputation. I personally prefer MongoEngine and feel very comfortable with it (maybe because I like its nice homepage and good documentation). There is also a very good opensource project named Mumblr which demonstrates a Django-MongoEngine-MongoDB combination, which I think a very good starter for any project. I'm developing a CMS for my own company using this app.
I've used MongoKit with Pylons before and it worked out good.
You might want to refer to this post though: MongoDB ORM for Python?
There is no stable support for mongodb using django framework. I tried using mongoengine, but unlike models, provided for admin in django framework, there is no support for mongoengine.
Correct if I am wrong.
Flask is the best framework to use with MongoDB. It has a mongodb library called flask-pymongo
Make sure you run the following commands before starting your project.
$ pip3 install Flask
$ pip3 install Flask-PyMongo
I have been doing some work in python, but that was all for stand alone applications. I'm curious to know whether any offshoot of python supports web development?
Would some one also suggest a good tutorial or a website from where I can pick up some of the basics of web development using python?
Now that everyone has said Django, I can add my two cents: I would argue that you might learn more by looking at the different components first, before using Django. For web development with Python, you often want 3 components:
Something that takes care
of the HTTP stuff (e.g.
CherryPy)
A templating language
to create your web pages.
Mako
is very pythonic and works with Cherrpy.
If you get your data from a
database, an ORM comes in handy.
SQLAlchemy
would be an example.
All the links above have good tutorials. For many real-world use-cases, Django will be a better solution than such a stack as it seamlessly integrates this functionality (and more). And if you need a CMS, Django is your best bet short of Zope. Nevertheless, to get a good grasp of what's going on, a stack of loosely coupled programs might be better. Django hides a lot of the details.
Edited 3 years later: Don't use mod_python, use mod_wsgi. Flask and Werkzeug are good frameworks too. Needing to know what's going on is useful, but it isn't a requirement. That would be stupid.
Don't lookup Django until you have a good grasp of what Django is doing on your behalf. for you. Write some basic apps using mod_python and it's request object. I just started learning Python for web-development using mod_python and it has been great.
mod_python also uses a dispatcher in site-packages/mod_python/publisher.py. Have a ganders through this to see how requests can be handled in a simple-ish way.
You may need to add a bit of config to your Apache config file to get mod_python up and running but the mod_python site explains it well.
<Directory /path/to/python/files>
AddHandler mod_python .py
PythonHandler mod_python.publisher
PythonDebug On
</Directory>
And you are away!
use (as a stupidly basic example):
def foo(req):
req.write("Hello World")
in /path/to/python/files/bar.py assuming /path/to is your site root.
And then you can do
http://www.mysite.com/python/files/bar/foo
to see "Hello World". Also, something that tripped me up is the dispatcher uses a lame method to work out the content-type, so to force HTML use:
req.content_type = 'text/html'
Good Luck
After you have a good idea of how Python interacts with mod_python and Apache, then use a framework that does all the boring stuff for you. Up to you though, just my recommendation
If you really don't want to delve into the frameworks - and you should, I heartily recommend Django or Pylons - there's still need to go down the road of CGI. This is a totally out-of-date technology, not to mention slow and inefficient.
There is a standard way of building Python web applications, and it's called WSGI. If you want to roll your own web app from scratch, this is absolutely the way to go.
That said, if you're just starting out, really you should go with one of the frameworks.
Python Wiki: Web Frameworks for Python
If you decide to use Django, the official tutorial is an excellent place to start. The Django Book is also free.
There are a couple of choices for web development. From my experience, your choice will again be dependent on your application. I used django and web.py in production and I am about to deploy an app based on pylons.
Django hides a lot of choices (comes with its ORM and templating). The documentation is extensive and well-written. There are many reusable app available for django, but you will likely to invest a little time in integrating them seamlessly. One thing mentioned on djangocon 08 was the fact, that there is cool stuff in django, which can't be easily
accessed in non-django projects.
web.py impressed me by its raw simplicity. Before I knew it, I wrote a small app (78 lines quasi-wiki) in it.
pylons feels like in the middle of both. I can use sqlalchemy and jinja, all in all a pleasant experience for the start.
Lookup Django.
Python can be used for web development, but there isn't a special language extension or anything in the language that will handle all the HTML generation or that works like PHP.
It's pretty much run through some sort of interpreter on a web server (CGI, mod_python, etc.).
I would recommend looking into Python Web Application Frameworks or how to write Python CGI scripts.
There are quite a few web frameworks for python out there, but the only one I've used is Django, and I really like it.
If you've got a few hours, do the tutorial, I promise you, you'll enjoy it :)
As others have mentioned, one of the more prominent python "offshoots" as you call them would be Django. It is a rather powerful framework that allows you to quickly and securely build web applications. The first place to look would be their overview which gives some insight as to what Django does as a framework.
Going through their tutorial taught me alot about the prominent Model-View-Controler design pattern and how it may be used in a web-development context. I found it a great way to start writing an application that worked and learn by improving it.