Pylons is a component based MVC web framework. It, like a lot of more recent MVC frameworks, is borrowing some ideas and concepts from rails in a less “opinionated “ way.
Out of the box Pylons has a preference for using SQL Alchemy for ORM (similar to NHibernate in philosophy) and Mako template engine (uses Python code for markup) . Now if you prefer SQLObject , or the Elixer dialect of SQL Alchemy for ORM and Genshi template engine pylons supports them all (and others). More importantly this means you have choice down the road to match your personal preferences or particular project complexity needs.
With Setuptools installed Pylons installation is type the following in a command prompt:
This will install everything needed to get started.
Were going to create a simple forum called Pylons Forum. Not exactly imaginative, but it requires authorization, db calls, and basic view logic. Just be glad its not a shopping cart or blog.
paster create –list-templates
We’re going to use the pylons template for now and type
paster create –t pylons pylonsforum
select enter to pick ‘mako’, then you’ll see:
type in true then hit enter.
cd into the pylonsforum directory and run dir(or ls depending on your platform)
should result in:
Now if this is what you see the key being “development.ini” file. Type
paster serve –reload development.ini
open up a browser to http://127.0.0.1:5000
First Controller and Test
Now that we have our structure setup go ahead and type the following:
paster controller home
you should see:
So we’ve created a controller and a functional test associated with that controller.
open the following url:
will bring up the obligatory “hello world”.
Next post I’ll being to cover using controllers and views.