views:

1179

answers:

9

Hi.

I'm a long-time PHP developer looking to try out Python for web development. I've used Python in the past a bit, but I'm still quite new at it.

I've taken a look at Pylons, and I have to say that it's extremely confusing to me. All the documentation I can find are just "copy and paste this" tutorials which don't seem to explain much.

For example, why can't controllers automatically render a specific view on a default template or something? Do I need to add a million import statements on top of every controller?

It's just that it feels so glued together - like there is no standardization between the components.

So what's the best way to learn Pylons?

Of course there's other options, but do you have something else to recommend? I'm not really looking for much - MVC, an ORM and some form generation would be more than enough to satisfy me.

I've also looked at Django, but from what I can gather, it's more of a thing suited for CMS with all the admin panels etc. than generic "web services" (or whatever the term is).

+7  A: 

If you're just exploring the wilderness, have a stronger look at Django.

It really has nothing to do with CMSs in the traditional sense. You create data models and yes, with a line, you can have an admin panel so you can manage your data. You can spin that into a traditional CMS, but that's not what it is by default.

I think you'll find Django's tutorials (and books) a lot more useful that the Pylons ones... Plus there's a lot more code floating around to help you out for Django.

Oli
agreed. take a few hours and do the django tutorial http://docs.djangoproject.com/en/dev/intro/tutorial01/ Also check out Dive Into Python http://diveintopython.org/toc/index.html
Adrian Mester
+5  A: 

You should probably learn Python via something other than a big MVC framework first -- those frameworks will make obvious sense once you do, and won't until you have. The idioms, the modules, the functions and data types, are all simple and intuitive but there are so many of them in a framework that you will be a bit overwhelmed (as you seem to be, this happens to everyone at some point.)

Start a little lower down -- install a database and a module for it, like psycopg2 or MySQLdb, or the included sqlite3. Learn the basics of urllib2 and something like lxml or BeautifulSoup and get comfortable pulling data from somewhere and feeding it to your database. Make some html forms and format them with Python's own string formatting methods a few times, write them to files and poke around them in your browser.

Then read and reread the Python wsgi spec and actually do the examples in the Pylons documentation, simple as they may seem. Instead of "hello world", figure out a way to get your little app to do something with the url it has been given, like return a welcome page or something from your database -- a text search, whatever. Keep doing this for a few hours or days until you start wishing someone had written something that would automate the url parsing, and eliminate or minimize the SQL queries, etc., and then you will be happy about all those import statements.

bvmou
Can you break that into paragraphs?
cdmckay
+3  A: 

I am a python newbie too. I have spent the last week playing with Django, and I think you are selling it short. It seems to have sufficient power to do most of the things I want to do in web apps. The only problems I have found so far are MS Sql Server support (not there) and the lack of database evolution. Both of these are apparently solvable with addins and may not be problems for you.

I haven't found any problems learning python along with Django.

You might also want to take a look at TurboGears 2 which is built on top of pylons with extra glue.

SeanX
+1. Django is extremely well documented.
muhuk
TurboGears 2.0 seems to bring Pylons and the Python stack a fair bit closer to Rails.I've played with Django and it seemed like a really good system for maintaining content-driven sites (or a cluster of them), but I didn't the like the way that it used it's own components rather than more standard libraries, or the way that it didn't encourage clean application structures.
Stuart Ellis
Turbogears2 is very powerful and full-featured, but it's certainly not for beginners! Turbogears gets its power by bringing in many best-of-breed open-source components and gluing them all together. To really learn it, you would have to learn all the components separately -- and there are a lot of them! Learning Django is much easier.
Nick Perkins
+1  A: 

Am afraid it is because Pylons is comparatively for people who have already got a clue of Python web frameworks and how to get things done with them. This doesn't mean that Pylons is hard, but because Pylons is very flexible and allows you to choose every piece of the puzzle as you want it is not easy for someone new to the web framework arena to adapt to it.

You should be starting with a comparatively rigid (in terms of flexibility of module level choices) framework like Django for a start. Django also enjoys a bigger and more active community compared to Pylons, and also a wonderful documentation (Pylons' documentation is also really good) and a book on using Django.

And if you want to start getting accustomed to Python and developing web apps with it try a smaller barebones framework like web.py so that you could get used to the MVC model that's prevalent in most web frameworks.

For the CMS part, there is already some projects out there for CMS based on Django. May be you can pick one up, play with it and customize it as per your requirements.

Technofreak
+8  A: 

Have you looked at the Pylons book? I think it does a much better job documenting and explaining how Pylons works. If you are really interested in Pylons, I'd start there.

Brett Bim
+3  A: 

+1 for the pylons book, it's invaluable for understanding the how and the why's of the framework and in general WSGI. After you read through and understand it, you'll be in a better position to not use pylons, which was kind of the original intent of the framework.

Tom Willis
+1  A: 

I like WHIFF myself (because I wrote it). Please let me know if you find my tutorials more helpful or not. http://whiff.sourceforge.net

Aaron Watters
+1  A: 

Django is the easiest way to go if you want to get started in Python web development. I have been learning and working in Django for the last few months, then I gave Pylons a shot. It isn't that hard to get into it if you know Python well and the MVC framework. You will see a lot of similarities with other frameworks.

Some might argue how explicit all these imports are but if you have a look at Rails, you will wonder where do things come from. Not that magic is a bad thing but it illustrates to you two extreme cases of a very explicit and implicit framework.

Embrace the current frameworks as they are and learn from them.

Thierry Lam
+2  A: 

Having just went through the Pylons learning curve I can say that the easiest way to learn it is to dive right in with an open mind.

Pylons provides a lot of structure. In return you pay the price of additional complexity.

Controllers don't automatically render a specific view on a default template because that is somewhat limiting. Sometimes I don't want to even render views. How about if I just want to return some JSON? Pylons is powerful in that it lets you choose what you want to do.

Pylons provides just a small amount of glue and some basic components that everyone uses. Then you build the rest depending on what libraries you want to use.

The 3 things you need to really understand in Pylons

  • routing.py (learn to love nice looking URLs)
  • controllers directory (all your logic)
  • templates directory
Jeff T