ArunRocks

Representing Anti-Monotonistic Tendencies
  • rss
  • Home
  • A little intro to Thrissur
  • Archives
    • Search
  • Resumé
  • About Me
    • Comment policy

Learning Pylons Through Tutorials

Arun bhai | Thu, Jun 26, 2008

Web Development is now getting dominated by frameworks. After the initial hype of Rails, Python based frameworks are getting more popularity especially after the release of Google App Engine. Nobody seems to be interested in building websites using PHP, even if they are highly experienced in PHP. This could mean two things:

  1. There will be more demand in Indian IT companies for PHP skills similar to Perl scripting skills these days :mrgreen:
  2. There will be soon be a viable competitor to the immensely popular Wordpress blogging platform from the Python/Ruby world

I have nothing against Wordpress. In fact, it is one of the easiest tools to deploy. But with tools like cPanel, deployment could be no longer a deciding factor for blogging platforms.

Coming back to the topic of Python Web Frameworks, there is a multitude of options. I have used some of these framworks and found them to be ‘pythonic’ in different ways:

  • Django Well documented. Tightly Coupled and ‘Batteries Included’
  • Pylons Extremely flexibility to Plug and Play components. ‘Fun to Hack’
  • web.py Great for beginners. Entire framework ‘fits in your head’

Pylons looks most appealing to me. So far it looks like the underdog largely overshadowed by Django’s presence lacking the marketing or love it deserves. A few weeks back I would have complained about the lack of Pylons tutorials on the web. A google search brought up several links pointing to the wiki tutorial. As many have pointed out, the wiki tutorial is too long and complicated for beginners. It would easily put off a beginner. It took me quite some time to realise that the best place to start learning Pylons is the Pylons Documentation itself and the best Pylons tutorial is the Flickr Search. Going through the documentation is almost feels like reading a book with every concept explained in detail.

Pylons currently seems to the having an edge over Django for enterprise application due to its well tested interface with SQLAlchemy. Django seems to be having a fairly recent branch for SQLAlchemy integration. Pylons typically uses Python eggs and VirtualEnv for deployment which is might seem a little complex to beginners, but once you try it once it is actually quite convenient. Most of the installation can be done from the command-line and it will be nearly an independent sandbox for Pylons development. However it might take sometime to understand other aspects of using python eggs such as uninstallation and creation of new eggs. I haven’t had much success with making a portable version of my Pylons installation on Windows though :(

My favourite templating engine is Genshi because it is very designer friendly(which also means it works with the tools a Designer has, not just that it is easy for a Designer to learn). I can easily do all HTML designing directly on my Genshi templates because they are valid HTML or XML documents. Almost all of Genshi’s logic can be hidden away as attributes which is a great idea. In fact, the templates are even valid XML which makes the creation of valid HTML pages a much more natural experience. Almost all XML tools and even HTML tools like Tidy will work flawlessly on Genshi templates due to these reasons.

Once you get used to Genshi’s templates, you might even use them for static web site designing. I am sure it will save you a lot of time whenever those last minute ’sidebar redesigns for every page’ pops up.

Bookmark this to del.icio.us | Digg | Furl | Netscape | Google Bookmarks | Technorati | reddit |

Comments
3 Comments »
Categories
Python, WordPress
Comments rss Comments rss
Trackback Trackback

V-day Special

Arun bhai | Sun, Feb 17, 2008

Here is a belated valentine’s day greeting from both of us.

This photo is a macro taken by Arun

For all my readers, I recommend visiting the microsite I had made earlier. Now it is written entirely in web.py. Thanks to my new website host, A Small Orange, I can create and host python based applications. I agree that there is no need to design a new blog in python again, but it is a great way to learn a new (anti-) framework. Web.py applications are really small and easy to understand and therefore, has less bugs.

Guess what, Jeff Atwood owns an ASUS laptop model (W3J) that is similar to mine (F3J). He is full of praise about the decision. Considering I took at least 2 months (the standard duration for yours truly to zero into an buying decision) to arrive at the decision, it seems well worth now :).

Bookmark this to del.icio.us | Digg | Furl | Netscape | Google Bookmarks | Technorati | reddit |

Comments
No Comments »
Categories
General, Python
Comments rss Comments rss
Trackback Trackback

Work Faster in Windows With Launchy and a few Python Scripts

Arun bhai | Tue, Dec 4, 2007

Eating the Mouse

Launchy is a great productivity tool and a cool way to impress your friends. You can launch any application by pressing a hotkey (say Alt+Space) and the first few letters of the application for eg: typing ‘gi’ will display the GIMP icon and pressing Enter will launch GIMP. You can download Launchy from its website and its beta is pretty stable (and gorgeous) on my XP laptop too.

Using Launchy gets pretty addictive and soon you will hate using the Start menu or even Explorer on Windows for opening applications or files. So I took the red pill and started automating the following things with a little help from Python:

  • Launching Intranet applications inside Internet Explorer (even if Firefox is your default browser)
  • Bringing minimized or overlapped windows to the foreground

Some Necessary Evil

Don’t get me wrong, I hate IE as much as you do. But the fact of life is that many web apps out there “Work best when viewed in IE” (TM). Even if you have launchy plugins to launch the web app, if your default browser is Firefox, it might show incorrectly. Here is the solution:

  1. Install Python and Pywin32
  2. Copy the following script to the Utilities directory (it will be in the path where you installed Launchy) and save it with a .pyw extension not a .py extension

In the above code replace the URL http://intranetapp/home with the URL of your choice.

Finally, open Launchy, right-click and say ‘Rebuild Index’.

No more Alt-Tabbing around

If you are like me, you’ll have a lot of windows open at the same time. I have tried increasing the task bar height and grouping similar windows feature in XP to manage them. But I always wish I could invoke commonly used open applications like my chat window in just a few keystrokes. Launchy doesn’t index open programs by default, but with some python magic I can show you how to bring some commonly used windows to the foreground:

  1. As before, install Python and Pywin32
  2. Copy the following script to the Utilities directory (it will be in the path where you installed Launchy) and save it with a .pyw extension not a .py extension

In the above code change the string Microsoft Excel - Expenses.xls with the title the window you would like to summon.

Finally, open Launchy, right-click and say ‘Rebuild Index’.

This works even if the window was minimized.

I hope, finally you can throw your mouse away. Ah… What a bliss!

Bookmark this to del.icio.us | Digg | Furl | Netscape | Google Bookmarks | Technorati | reddit |

Comments
11 Comments »
Categories
General, Python, launchy, productivity
Comments rss Comments rss
Trackback Trackback

Making Python Scripts Show Windows-friendly Errors/Stacktrace

Arun bhai | Wed, Jun 20, 2007

Most of us love to distribute our python programs to others once you have finished coding a neat little script. For Windows users we package it using Py2exe or cx_freeze. However, many of the end-users will not be happy with a black command window popping up, say, when an error is thrown.

Of course the alternative is to write a full blown GUI application using WXPython or PyFLTK. Even the latter, though quite lightweight, adds several megabytes to the distribution, when all you need is a simple message-box indicating an error or showing some informational text. Clearly, its an overkill for your throwaway python scripts.

This is the kind of problem I typically face and I have found a good solution. The answer is ctypes library which comes as a part of the standard distribution from Python 2.5 onwards. It simply calls the messagebox function from user32.dll (which is always present in a windows installation). With the main problem solved, what remained was to obtain the error text and stack trace.

Let’s see how the code looks like:

EDIT: This is how it looks like in PyMail, one of my scripts-that-grew-into-an-app ;)

Screenshot of a Python Stacktrace in a Messagebox

Bookmark this to del.icio.us | Digg | Furl | Netscape | Google Bookmarks | Technorati | reddit |

Comments
No Comments »
Categories
General, Python, Technical, py2exe
Comments rss Comments rss
Trackback Trackback

Windows+Python Integration Like Unix shell

Arun bhai | Fri, Aug 12, 2005

Remember how in UNIX how easy it was to run python scripts? Just type name of the script. No need to even type the extension .py

I got soon fed up with typing

C: > python foo.py

in windows. Digging up some Microsoft documentation, I soon found a way to simply type

C: > foo

and make it work. How? read on…

All you need is to create a batchfile, say ’startme.bat’ with the two lines

ASSOC .py=PythonScript
FTYPE PythonScript=python.exe %1 %*
set PATHEXT=.py;%PATHEXT%

If you want this to be the default behaviour everywhere, put this in ‘autoexec.bat’. But wait, we have a better way to do this. You can make ’startme.bat’ work like ‘.bashrc’ in UNIX by registry hack. Create a REG file, say ‘cmd-changer.reg’ with the contents:

REGEDIT4
[HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor]
“AutoRun”=”startme.bat”

Now opening this file will merge it to the registry. Now ’startme.bat’ will be run every time you open the command prompt say by typing ‘cmd.exe’ in the Run command box. Hope this helps!

Bookmark this to del.icio.us | Digg | Furl | Netscape | Google Bookmarks | Technorati | reddit |

Comments
No Comments »
Categories
General, Python, Technical
Comments rss Comments rss
Trackback Trackback

Is Python Intellisense Possible in Emacs?

Arun bhai | Tue, Jun 14, 2005

Like the search for the Elixir of youth or philosopher’s stone,
I was looking for some kind of Intellisense
feature for Python in Emacs which I have grown used to since my windows
programming days. Yes I’m referring to the little drop down list
that helps you auto complete class members. I’m also referring the
tool-tip that appears which shows a functions signature when you are
calling it. I know that PythonWin, my python editor of choice,
already does this. But I intend to use Emacs as my IDE.
It seems that you have two alternatives, both have issues
as you will see:

py-complete - Not yet Windows ready?

Firstly py-complete seems to require Pymacs. Now, this was
not very obvious. The idea of python helping in completion seems to be
very cool and nearly worked without pymacs. Seems pymacs is not quite
well supported in Windows. As soon as I read this I sort of gave up.

Semantic Flopped

Then, I installed CEDET 1.0 (beta 3) which gives you Semantic inspired by this post. It
seemed to be a pain to install the whole thing until I discovered that
you have to keep certain things in the load-path. Finally this is what
I added to my .emacs file

;; Set up load path
(setq load-path (append (list (concat use-home "site/cedet/speedbar")
(concat use-home "site/cedet/common"))
load-path))
(load-file "~/site/cedet/common/cedet.el") ;; Load CEDET
(semantic-load-enable-minimum-features)

Now as the post suggests, we have a fully working speedbar but
auto-completion is pretty much weird. For eg: M-x
semantic-analyze-possible-completions describes the scopes you are
currently in.

Conclusion

Both approaches are really good though quite different. They haven’t
made use of the emacs tool-tip library either. Since this is a
crucially lacking feature in Emacs, I might as well do a bit of R&D
on this before giving up the dream.

Bookmark this to del.icio.us | Digg | Furl | Netscape | Google Bookmarks | Technorati | reddit |

Comments
1 Comment »
Categories
General, Python, Technical
Comments rss Comments rss
Trackback Trackback

Your Email:

Categories

  • emacs
  • General
  • greasemonkey
  • indie
  • launchy
  • Pocketmod
  • productivity
  • py2exe
  • Reviews
    • Books
    • Movies
  • Short Stories
  • Technical
    • Gaming
      • Unni
    • Python
    • WordPress

Recent Posts

  • Ledger’s Joker Chills, Thrills and Entralls
  • Reading Hindu Online Made Better with Greasemonkey
  • Better Fonts Tip: Biggest Improvement in Ubuntu Appearance
  • Best Dialogs of Salim Kumar
  • Learning Pylons Through Tutorials

Recent Comments

  • Arun bhai on Best Dialogs of Salim Kumar
  • Thomas on Best Dialogs of Salim Kumar
  • Nidhish on Best Dialogs of Salim Kumar
  • abhilash on Learning Pylons Through Tutorials
  • Bookmarks about Ubuntu on Better Fonts Tip: Biggest Improvement in Ubuntu Appearance

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org

Bookmarks

del.icio.us/arun_ravindran I am arun_ravindran on del.icio.us
add arun_ravindran to your network Add me to your network
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox