Squeeze of Python

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

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.