Squeeze of Python

This is a free Python Magazine and personal blog of S Ramdas.

Sunday, March 05, 2006

Myghty, Pylons and TG

There is little doubt that Myghty in terms of features beats other templating languages. However this one is a bit of a monster, and I have now spent almost four hours trying to learn it. So far it is good. But I am still looking for clues on how I can integrate CSS inside a Myghty document.

Since Myghty is based on Mason, and since there is an excellent book available online on Mason, I am also reading Mason Book online. However Perl is often too cryptic for my more refined ( and sophisticated Pythonic tastes)

Meanwhile I must confess that I am still not able to take a decision between TG and Pylons. Here are some points that I noted on both these products. Mind you these are newbie issues. I have never done web programming myself, only managed projects.


TG

TG promised a lot, but things are very unstable since the upgrade to 0.9a1. First of all I am not able to upgrade some of my PCs to 0.9a1. Despite complaining in the TG forums, no one has bothered to even help me.

From what little I understand, handling Kid and extending CherryPy is likely to be a pain.

On the positive front, the number of enthusiasts backing TG is huge, and according me is ten times that of Pylons. This is critical!

Pylons
Pylons is simple. But the work seems to be very slow. There are no good tutorials or documentation. This is indeed a huge let down. Again, I am getting no answers to my silly queries on the mailing list. I am hoping that in the coming days things will improve.

Meanwhile I think working on Myghty is a good idea. Somehow the Pylons team is not doing a good job of marketing the project.

Tuesday, February 14, 2006

Myghty is mighty interesting

Everyone has their own favorite templating engine these days on Python. I have tried Cheetah and Kid, and found both of them lacking in terms of features. I am having a lot of problems with Kid templating system, when I work on TurboGears. Kid is throwing up a few errors, and although it kind of forces me to write good XML, I think the system gets a bit too mean. However Kid has limitations, and for the pain I guess it is not worth it.

Pradeep Gowda of btbytes.com fame pointed me to Myghty and I am starting to appreciate it. Myghty is based on Mason, which helps you to embed Perl in HTML.

From the Myghty web site

"Advantages of Myghty

· 100% support for all of HTML::Mason's industry-proven featureset, and more
· A flexible and extensible caching system comes built-in, available at the component, page, and superpage levels through simple tags, or programatic access anywhere. Supports memory, file, DBM and memcached backends.
· Templates embed 100% real Python, Python control structures, Python whitespace
· Real .py and .pyc modules generated on-the-fly
· mod_python, CGI, WSGI support built-in, tested, on the road right now, including with FCGI, Lighttpd and Python Paste - runs standalone out of the box too. Also supported with CherryPy and Turbogears via the BuffetMyghty template adapter.

· Built-in Session support for all platforms - doubles as a drop-in replacement for mod_python's session, also supports file and memcached backends.

· The only place in Python where you'll get the original template inheritance model - the most widely used and feature-rich

· Unique Module Components system allows any arbitrary function or object method within a Python module to intermix with templates freely, or be mapped to URL resolution - they are the ideal environment-agnostic MVC controller

· A ruleset-driven Resolution engine, the only one of its kind - resolves components based on paths, regular-expressions, across multiple directory structures and even within modules and their attributes. Create logic-driven chains allowing unheard-of amounts of URI resolver flexibility, and add your own rules. Myghty's resolver can match any URI to any code or template - guaranteed."



I will write a very small Myghty example in next blog to illustrate the power of Myghty.

Friday, February 10, 2006

Pylons vs TurboGears

I have been trying to zero down on a Python web framework for quite some time. I know I have company since BDFL himself is searching for an option.

The idea is to build a CMS system that is practical to current editorial teams I work with. Most portals/ news sites, I am building have distributed teams, and I am finding it difficult to scale the existing PHP based code base. Mind you the CMS systems we use for Developer IQ and now for Marketflash, lets you file a story in less than 30 seconds and is good enough for current day requirements.

Django looks good, and is the most stable of the new generation Pythonic frameworks.

Last two years I tried not once, not twice, but umpteen times to learn Zope and then Plone. I even attended a three day training course which came free of course. I managed to create a few pages, and even a half baked tiny application. Now I have given up the Zope and Plone stuff for good.

Plone is cool and is very good, if you want to set up an Intranet kind of an application. In fact I will recommend it over any other available free stuff that I have played around with. Can’t say much about stuff I have not seen.

However, the learning curve just seems to be too steep.

Django is quite elegant, but somehow TurboGears was interesting as CherryPy is a web server that I am familiar with. I had almost finalized on TG, before someone pointed me back to Pylons. What attracted me to Pylons were the simple design and the Myghty template system.

Now the choice is between TG and Pylons. I am looking at choosing between either of them in next 20-30 days.

I need to make a decision based on the following factors

1) The project needs to get into a state of stability (within the next 3-4 weeks) where the code will not break as it stabilizes to a 1.0x. I am hoping to start off on developing a more complex distributed content management system by that time.

2) The project needs to be installed on a regular server which dishes out LAMP pages belonging to my existing ISP.

3) The web server should be able to handle 5000 requests a second. The LAMP systems which we use have survived peak traffics of similar counts with élan.

4) I know it’s difficult to know now, but I want to go with the project, that will have longer and faster legs. The predicament with most Open Source projects is they lose steam midway, and this can be very frustrating.

Those were the business considerations.

On Technical front, I am not able to figure out which among the two is better?


If you compare the learning curve I guess TG and Pylons are almost on the same tangent. What is missing (at least as I write) is that there is no Ajax plug-in read made with Pylons, and at the same TG lacks caching.

Both uses SQLObject and Formencode. TG uses Kid while Pylons has betted on Myghty.

Perhaps someone who has worked with both the frameworks can write a note on "Pylons vs TG" and can help me and many more like me.

Wednesday, September 21, 2005

BangPypers Python CD

Bangalore Python User Group a.k.a BangPypers is planning to put together a Python CD containing a compilation of Python related software including editors, toolkits, third party modules, frameworks and web servers. We are also providing lots of documentation including at least three free books and several articles. In short we intend to have practically all Python related software. Initially we are planning to release a CD consisting of approximately 300 MB of software each for Windows and Linux. The idea is to have a CD where you will have all the software that you require for Python development. Since popularity of Python is growing at exponential rates it is likely that this will be a project that will never end. May be very soon this will become a Python DVD project.

We have a wiki set up on www.bangpypers.org. We welcome all to add their favorite Python software in the CD. Please note that we can only carry software that is freely distributable, that is the license should not prohibit us from giving software away on the CD.

If you have any suggestions to offer do mail me on ramdaz [at] gmail [dot] com.

Tuesday, September 13, 2005

Python Magazine

I love Python! And I thought I must chronicle my experiments with Python. But if you have a code which is Pythonic do mail me on ramdaz at gmail dot com. I will put it up here. This is a free magazine for all Python lovers and a personal blog of mine.