Sunday, January 10, 2010

Debugging WSGI for deployment with Django on Apache2

WSGI by default blocks all writes to stdout/ stderr. While this is a good thing since it ensures that the django application can't interfere with the CGI in/out streams, it poses problem for debugging issues that may come up during deployment.

The method to debug such issues is to redirect the prints to stderr stream - which is captured in /var/log/apache2/error.log

    import sys
    print sys.stderr, ""



Tuesday, March 17, 2009

Blogging from emacs (followup)

After spending some more time with gblogger and trying to get things to work with Emacs/Zsh; I found e-blog through Xahlee's blog post.

I must say, I am pleased with the interface exposed by this package and the ease with which it installed and works - even for editing existing blog posts. Needless to say, I have switched to e-blog for posting entries to this blog.

Monday, March 16, 2009

Gblogger New Entry

Getting gblogger to work on zsh proved to be easy after a little bit of working knowledge of the gblogger code.

curl/ zsh appears to be stricter with URLs. So just changing URLs so that they are surrounded by single-quotes appears to have fixed this issue.

For this I needed to change gblogger code at two places:


g-auth.el:

(defvar g-auth-url-pattern
"'https://www.google.com/accounts/ClientLogin?service=%s'"
"URL to login to Google services.")


And,


gblogger.el:

(defun gblogger-new-entry (url)
"Create a new Blog post."
...
...
(setq gblogger-this-url (concat "'" url "'" ))
...
...
(substitute-command-keys "Use \\[gblogger-publish] to publish your edits ."))))


Notice the single-quote in both of these changes.

The change above is ofcourse not the final change - to make the code portable across all shells, this change should be made based on shell being used - but this gets us going in the right direction with gblogger/ Emacs on zsh.

Friday, March 13, 2009

Attempts to setup Blogger interface within Emacs


Recently I discovered TV Raman's gblogger interface for writing blogs on Google's Blogger service.

In the last few months, I have been trying to migrate my work-environment within Emacs so naturally I am very excited about this. But setting this up on my laptop proved difficult.

Firstly it appears that gblogger doesn't work with zsh. So I switched to using 'bash' just for this purpose (though hope is that I will be able to resolve this issue and switch back to zsh since that's my preferred shell.)

With this change I was able to get the ability to publish blogs. But editing existing blogs still does not work.

Some differences appear to have cropped up between the "edit interface" used by gblogger since the time it was released (two years ago).

To start with, I wasn't able to even correctly "fetch" an entry that I had posted earlier. To get around that it appears that the g-xsl-transform-region needs to be called "before" any html-unescaping is done on the *atom entry* buffer.

So I removed the call to g-html-unescape-region from -get-entry () function and moved to be after g-xsl-transform-region () call in -edit-entry ().

The above got me the entry in *atom entry* buffer. But a few html entities are still not getting escaped. These extra entities result in issues with publishing.

I will continue to investigate around this in my spare time - but just wanted to post this history for posterity.