Sandboxing emails in Django

by Sumit Chachra on July 10, 2010

Its usually good to sandbox your QA / staging environments so that they don’t shoot out emails to real email addresses (say you’ve made a copy of your production database). Django 1.2 and their email backends make it really easy to do so.


Here’s a testing email backend I wrote. Simply drop in a email address associated with the DEFAULT_TO_EMAIL setting in your settings.py. Also set the EMAIL_BACKEND in settings.py to the class below.


This also takes care of cases where in your code you’re sending a “mass mail” (using send_mass_mail), it’ll only send one out.
from django.core.mail.backends.smtp import EmailBackend
class TestingEmailBackend(EmailBackend):
    """
    Used in dev and qa
    """
    def send_messages(self, email_messages):
        """
        Overrides the to email address. Also if there are tons of messages being sent out then it reduces them to
        1 message.
        """
        if len(email_messages) > 1:
            email_messages = (email_messages[0],)
        email_messages[0].to = [django_settings.DEFAULT_TO_EMAIL,]
        super(TestingEmailBackend, self).send_messages(email_messages)

{ 0 comments }

Moving Wordpress mu to a different domain

by Sumit Chachra on March 4, 2010

So I have a Wordpress MU setup where we’re hosting a bunch of sites/blogs (email me at sumit AT tivixlabs.com if you’re interested in one).

As with all my Django webapps I wanted to replicate all the sites on qa for testing purposes (so that we’re not messing production sites with plugin / wordpress upgrades etc.). The problem is the qa site runs on a different domain (say domain2.com) than the production MU install (say domain1.com).

Since my stores the domain in 1 file (easy to fix) and a bunch of db tables, the easy solution is to:

  • Make a copy of entire wordpress directory and put the correct domain in wp-config.php in this line: define(‘DOMAIN_CURRENT_SITE’, ‘domain2.com’ );
  • Take a dump of your existing MU installs database. Open that dump file and do a replace of all “domain1.com” strings with “domain2.com”. Next do a replace of “domain1″ with “domain2″. Source this new dump into the new database for the new MU instance.

Thats it. These 2 steps should be it. Your MU site should now run like your old one, but at domain2.com and all existing sites/blogs will run at old-sub-domain.domain2.com too!

{ 0 comments }

On project management, bug/issue tracking and source control

by Sumit Chachra March 4, 2010

There seems to be a big disconnect between project management, bug/issue tracking and source control solutions out there. Simply put in most companies these systems don’t talk to each other as much as they should.
How have I solved the problem. I’m using bitbucket.org for source control that talks nicely with LighthouseApp which I use mainly [...]

View Comments Read the full article →

Fanning/Following is the new SEO?

by Sumit Chachra September 6, 2009

So lots of friends have been messaging and emailing me about my bizarre Fanning behavior on Facebook. Weirdly none complain when I fan someone/some brand on Twitter. I guess cause that affects my feed, not theirs (Facebook apparently informs them about my fanning?).
In any case, I thought I’ll fire up a blog post about it, [...]

View Comments Read the full article →

My thoughts on Yahoo!

by Sumit Chachra February 22, 2009

I’ve been thinking of blogging about my employment with Yahoo! for a while, but never got around to it. Reading today, about yet another impending Yahoo! reorg, I decided to write about what I felt like while I was there, what worked, what didn’t, and how Yahoo! can get out of the rut it finds [...]

View Comments Read the full article →

Givix.org – Giving while shopping!

by Sumit Chachra November 28, 2008

As many of you know I recently started working at Tivix. Working to solve problems faced by social entrepreneurs and Non-Profits is a good feeling. I came up with an idea similar to igive (there are others out there too), but wanted to make it simpler and easier to use (without forcing people to login [...]

View Comments Read the full article →

Mercurial Hosting that rocks – www.bitbucket.org/

by Sumit Chachra October 23, 2008

So I started a new gig this week, and I have become addicted to using Mercurial in my previous job for revision control of code. Mercurial rocks !
I didn’t really want to host the repository myself and have the additional headache of backing it up etc. (we’re a small early stage startup). I used Assembla [...]

View Comments Read the full article →

Google app engine feature request!

by Sumit Chachra June 24, 2008

New API’s that would be awesome:
+ Friend list API to get list of friends (users) of currently logged in user. This will enable sharing applications.
+ Jabber messaging api (for currently logged in user and/or any of his/her friend(s)). Real-time messaging anyone?
+ API to schedule execution of arbitrary code at regular time intervals, which can span [...]

View Comments Read the full article →

Feature requests for Amazon.com

by Sumit Chachra March 10, 2008

Although the Amazon UI has had a reasonably good overhaul, its been pretty much cosmetic. I like the fact that they have more intuitive dropdowns, a large cart icon and a navigation panel on the left. Sadly the number of clicks I require to accomplish a few tasks and few of the under-performing features leave [...]

View Comments Read the full article →

The Intelligent RSS/Atom feed

by Sumit Chachra March 2, 2008

This post could easily have been named “Targeted Blogging” or “Feature requests for Feedburner”
So I started thinking about a RSS/Atom feed that is intelligent. Meaning each of my blog’s feed subscribers can potentially be offered unique content. So let me present a few scenarios:
- Wouldn’t it be great to be able to write [...]

View Comments Read the full article →
Powered by Tivix