<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7419273247922290553</id><updated>2012-02-16T17:50:06.447-08:00</updated><category term='exception'/><category term='DJango models joins extra values functions'/><category term='django tests best-practices'/><category term='MX mails postfix emailing'/><category term='django'/><category term='python'/><category term='error'/><category term='utility'/><category term='flup'/><title type='text'>Technology Learning and Unlearning</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://techbookmarks.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7419273247922290553/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://techbookmarks.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>serendipity</name><uri>http://www.blogger.com/profile/01814313183465654189</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7419273247922290553.post-725465206413556069</id><published>2009-03-04T05:20:00.000-08:00</published><updated>2009-03-04T05:21:50.988-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='django tests best-practices'/><title type='text'>Appropriate placement for my testcases belonging to a non-app in Django</title><content type='html'>I have built my website in Django. And like any other django project I have got apps inside the project root directory and some special folders like(extensions a.k.a custom django command extensions). With an app, we dont have any problem with having testcases. "tests.py" inside the app directory will be the solution. But for a special folder(which is not an app or which doesn't have a models.py) where do I place the testcases. I tried placing the tests.py inside the extensions directory and it said the directory is not a model and unable to run the tests. HOw do I solve this? How can I have a proper placement of testcases related to non-apps?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7419273247922290553-725465206413556069?l=techbookmarks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techbookmarks.blogspot.com/feeds/725465206413556069/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techbookmarks.blogspot.com/2009/03/appropriate-placement-for-my-testcases.html#comment-form' title='35 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7419273247922290553/posts/default/725465206413556069'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7419273247922290553/posts/default/725465206413556069'/><link rel='alternate' type='text/html' href='http://techbookmarks.blogspot.com/2009/03/appropriate-placement-for-my-testcases.html' title='Appropriate placement for my testcases belonging to a non-app in Django'/><author><name>NandaKishore</name><uri>http://www.blogger.com/profile/04055192631083104247</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>35</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7419273247922290553.post-3811155355203246903</id><published>2009-02-23T05:56:00.000-08:00</published><updated>2009-02-23T06:12:38.787-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MX mails postfix emailing'/><title type='text'>Hosting an Email server and receiving all mails pertaining to @mysite.com</title><content type='html'>I have question regarding emails sent/received by any website out there.&lt;br /&gt;Assuming its mysite.com. Everyuser will be&lt;br /&gt;getting an email address say something like j...@mysite.com. Any&lt;br /&gt;person using the same website or any other website or any one on the&lt;br /&gt;planet can send an email to j...@mysite.com and for jack there is a&lt;br /&gt;Inbox feature built into his dashboard, where he will be seeing all&lt;br /&gt;these emails(forget about jack sending emails to anyone, now). So to&lt;br /&gt;achieve this,  I have changed MX records of my site(in godaddy) to:&lt;br /&gt;Priority:10&lt;br /&gt;Host:@&lt;br /&gt;Goes To:www.mysite.com.&lt;br /&gt;&lt;br /&gt;And the MX records lookup says:&lt;br /&gt;;; ANSWER SECTION:&lt;br /&gt;www.mysite.com. 3600 IN CNAME mysite.com.&lt;br /&gt;mysite.com. 604800 IN MX 10 www.mysite.com.&lt;br /&gt;&lt;br /&gt;And I have configured postfix on my production machine(www.mysite.com&lt;br /&gt;server) to receive all mails. Even then its not receiving any emails&lt;br /&gt;(all getting bounced). May I know whats happening? So MX records is the only one which will be responsible for any screwups? I have tried many sites like &lt;a href='http://stackoverflow.com/questions/575545/why-my-postfix-not-receiving-mails-on-my-production-machine'&gt;stackoverflow&lt;/a&gt; but&lt;br /&gt;didn't receive any help. Please help me.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7419273247922290553-3811155355203246903?l=techbookmarks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techbookmarks.blogspot.com/feeds/3811155355203246903/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techbookmarks.blogspot.com/2009/02/hosting-email-server-and-receiving-all.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7419273247922290553/posts/default/3811155355203246903'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7419273247922290553/posts/default/3811155355203246903'/><link rel='alternate' type='text/html' href='http://techbookmarks.blogspot.com/2009/02/hosting-email-server-and-receiving-all.html' title='Hosting an Email server and receiving all mails pertaining to @mysite.com'/><author><name>NandaKishore</name><uri>http://www.blogger.com/profile/04055192631083104247</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7419273247922290553.post-6281019591234347074</id><published>2009-02-11T23:06:00.000-08:00</published><updated>2009-02-11T23:54:07.078-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='flup'/><category scheme='http://www.blogger.com/atom/ns#' term='django'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='exception'/><category scheme='http://www.blogger.com/atom/ns#' term='error'/><category scheme='http://www.blogger.com/atom/ns#' term='utility'/><title type='text'>Simple Django/python utility to check all the import statements in your project</title><content type='html'>&lt;span style="font-family:arial;"&gt;As I mentioned in my &lt;/span&gt;&lt;a style="font-family: arial;" href="http://techbookmarks.blogspot.com/2009/02/django-doesnt-suck-ok-but.html"&gt;previous posting&lt;/a&gt;&lt;span style="font-family:arial;"&gt;, I was stuck with Flup exceptions and I am trying to implement what Maxx had &lt;/span&gt;&lt;a style="font-family: arial;" href="http://techbookmarks.blogspot.com/2009/02/django-doesnt-suck-ok-but.html?showComment=1234357680000#c8800245691860109023"&gt;&lt;span style="text-decoration: underline;"&gt;suggested&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:arial;"&gt;. But one interesting thing I did, just before MAXX suggested, to check all the import statements in my entire project codebase. Ofcourse this is not a Django level thing, but at the python level. I started writing one and made that a Django command extension, run as python manage.py imports_checker. It helped me in identifying many faulty imports which could be coined as one of the culprits for the "flup's dreaded exception". The code is mentioned below:&lt;/span&gt;&lt;br /&gt;&lt;pre name="code" class="python"&gt;&lt;br /&gt;class Command(NoArgsCommand):&lt;br /&gt;    option_list = NoArgsCommand.option_list&lt;br /&gt;    help = "Scans through the entire project directory and collects all the stale/obsolete import statements"&lt;br /&gt;    requires_model_validation = True&lt;br /&gt;&lt;br /&gt;def import_statement_extractor(self,directory_path,python_file):&lt;br /&gt;    python_file = '%s/%s' % (directory_path,python_file)&lt;br /&gt;    file_content = open(python_file).readlines()&lt;br /&gt;    for line in file_content:&lt;br /&gt;        line = line.strip()&lt;br /&gt;        if line.startswith('from') or line.startswith('import'):&lt;br /&gt;            try:&lt;br /&gt;                exec(line)&lt;br /&gt;#                    print '%s:==&gt;:%s:Pass' % (python_file,line)&lt;br /&gt;            except ImportError:&lt;br /&gt;                print '%s:XXX:%s:Fail' % (python_file,line)&lt;br /&gt;&lt;br /&gt;def directory_py_files(self,parent_directory):&lt;br /&gt;   import os&lt;br /&gt;   directory_generator = os.walk(parent_directory)&lt;br /&gt;   directory_info = directory_generator.next()&lt;br /&gt;   for file in directory_info[2]:&lt;br /&gt;       if file.endswith('py'):&lt;br /&gt;          self.import_statement_extractor(directory_info[0],file)&lt;br /&gt;   for directory in directory_info[1]:&lt;br /&gt;       if not directory.startswith('.'):&lt;br /&gt;          print '\n'&lt;br /&gt;          self.directory_py_files('%s/%s' % (parent_directory,directory))&lt;br /&gt;   &lt;br /&gt;def handle_noargs(self, **options):&lt;br /&gt;    from django.conf import settings&lt;br /&gt;    self.directory_py_files(settings.ROOT_PATH)&lt;br /&gt;&lt;/pre&gt;This is a generic command, it does not check the settings.INSTALLED_APPS setting for cleaning up imports but it does a decent job of identifying all stale or obsolete imports.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7419273247922290553-6281019591234347074?l=techbookmarks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techbookmarks.blogspot.com/feeds/6281019591234347074/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techbookmarks.blogspot.com/2009/02/simpledjango-python-utility-to-check.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7419273247922290553/posts/default/6281019591234347074'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7419273247922290553/posts/default/6281019591234347074'/><link rel='alternate' type='text/html' href='http://techbookmarks.blogspot.com/2009/02/simpledjango-python-utility-to-check.html' title='Simple Django/python utility to check all the import statements in your project'/><author><name>NandaKishore</name><uri>http://www.blogger.com/profile/04055192631083104247</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7419273247922290553.post-4245038185317411376</id><published>2009-02-09T09:29:00.000-08:00</published><updated>2009-02-11T23:58:34.904-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='flup'/><category scheme='http://www.blogger.com/atom/ns#' term='django'/><title type='text'>Django doesn't suck ok! But.....</title><content type='html'>I am a big fan of Django and working on it is really exciting(still after 2 years. I was from java world before). But these days its driving me nuts in one context. Its with my deployment stack. I am using lighttpd + flup + django combination to run my website. It was running fine till recently and then the problem started...&lt;br /&gt;&lt;br /&gt;I am facing the dreaded "Unhandled Exception" raised by Flup. The sad part is its raised at the webserver (lighttpd+flup as I call fcgi level) level and not at the application level(Django). So no 500 email is raised about where the problem is.&lt;br /&gt;&lt;br /&gt;Our entire team struggled hard to cleanup the codebase, incase of any ambigous imports and someones of that sort, just to be eliminate the chances of raising errors due to the ambiguous imports. And we cleaned up many things in the code. Still the same exception.&lt;br /&gt;&lt;br /&gt;I checked the lighttpd logs. All I see is "Interface Error/Connection already closed." Its only occurring when my applicaiton is running in FCGI mode. So the problem is with how flup is actually dealing with my code(application).&lt;br /&gt;&lt;br /&gt;To be frank I am really frustrated with Flup's error handling. It doesn't tell you anything. Worst of all, it shows the same "Unhandled Exception" to the Users. At one point I started posting into recently popular programming questions site &lt;a href="http://stackoverflow.com"&gt;stackoverflow.com&lt;/a&gt; to get some technical help and &lt;a href="http://stackoverflow.com/questions/527237/unhandled-exception-in-flup"&gt;made a posting&lt;/a&gt;. I received a few answers which were actually good, but made my opinion about Flup far more worser than I could ever imagine. So I finally decided to replace flup in the whole website configuration stack. But I stumbled upon django's fastcgi.py(which is responsible running django in fcgi and btw thats how I run my app). It had flup dependancies. What the heck? Django is having hardcoded dependancies with the package &lt;a href="http://www.saddi.com/software/news/archives/58-flup-1.0-released.html"&gt;whose author itself is not using it&lt;/a&gt;? Which means I cant bypass flup till I use Django? How do I get pass this? I dont want to leave Django no matter what, at the same time I cant have my users see this "Unhandled Exception" page just because Django depends on Flup. Now tell me what should I do?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7419273247922290553-4245038185317411376?l=techbookmarks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techbookmarks.blogspot.com/feeds/4245038185317411376/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techbookmarks.blogspot.com/2009/02/django-doesnt-suck-ok-but.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7419273247922290553/posts/default/4245038185317411376'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7419273247922290553/posts/default/4245038185317411376'/><link rel='alternate' type='text/html' href='http://techbookmarks.blogspot.com/2009/02/django-doesnt-suck-ok-but.html' title='Django doesn&apos;t suck ok! But.....'/><author><name>NandaKishore</name><uri>http://www.blogger.com/profile/04055192631083104247</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7419273247922290553.post-179119148494763866</id><published>2009-02-02T11:50:00.000-08:00</published><updated>2009-02-02T12:17:15.920-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DJango models joins extra values functions'/><title type='text'>Django Models Tweaks.</title><content type='html'>I was struggling with joins while using DJango models. After some searching i got some valuable inputs so I have crystallized it according to my understanding.&lt;br /&gt;&lt;br /&gt;Let us take an example of a Model - UserDetails which contains other including age and address .&lt;br /&gt;My intention is to query only age and address - then&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;user_details = UserDetails.objects.all().values('age','address')&lt;/span&gt; should return a &lt;span style="font-weight: bold;"&gt;dictionary&lt;/span&gt; of results with keys 'age' and 'address'.&lt;br /&gt;This is easier to compute and I feel that it is a better programming practice to query only the data which we would be processing.&lt;br /&gt;&lt;br /&gt;Coming to the issue of joining two Models and displaying a common result.&lt;br /&gt;The first model is the &lt;span style="font-weight: bold;"&gt;UserDetails &lt;/span&gt;Model ( user_details table ) and the &lt;span style="font-weight: bold;"&gt;UserFoodHabits&lt;/span&gt; Model ( user_food_habits table )&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;user_details = UserDetails.objects.all().extra(tables=['user_food_habits'],where=['user_details.food_habits_id = user_food_habits.id'],select={'habit':user_food_habits.habit, 'habit_type':user_food_habits.type})&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Please note that the where clause is written following the raw SQL syntax.&lt;br /&gt;&lt;br /&gt;The resulting query set would contain all the attributes of the UserDetails object and additional keys for 'habit' and 'habit_type'. The following piece of code illustrates that.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;for user in user_details:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;      print 'Name %s, Age %s , Habit %s, Type %s ' % (user.name, user.age, user.habit, user.habit_type)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;DJango models do not however officialy support group bys and aggregate functions. So it cannot be used with the extra parameter.&lt;br /&gt;But there is a workaround for it :&lt;br /&gt;&lt;a href="http://www.evanreiser.com/2009/01/howto-group-by-in-django.html"&gt;http://www.evanreiser.com/2009/01/howto-group-by-in-django.html&lt;/a&gt;&lt;br /&gt;Apparently DJango 1.1 would have better support for aggregation and stuff !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7419273247922290553-179119148494763866?l=techbookmarks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techbookmarks.blogspot.com/feeds/179119148494763866/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techbookmarks.blogspot.com/2009/02/django-models-tweaks.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7419273247922290553/posts/default/179119148494763866'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7419273247922290553/posts/default/179119148494763866'/><link rel='alternate' type='text/html' href='http://techbookmarks.blogspot.com/2009/02/django-models-tweaks.html' title='Django Models Tweaks.'/><author><name>serendipity</name><uri>http://www.blogger.com/profile/01814313183465654189</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7419273247922290553.post-583292025013383404</id><published>2008-12-20T21:27:00.000-08:00</published><updated>2008-12-20T21:33:37.525-08:00</updated><title type='text'>A small step.</title><content type='html'>My learning/unlearning of open source technology started about 2 years ago with my college project. Although it was very superficial , it was a start alright.&lt;br /&gt;Now i have undertaken the challenge of experting open source techs like Linux, Python, Django for good. Before this my technology concentration was limited to Windows, J2EE technologies like Hibernate, Spring , Tapestry etc.&lt;br /&gt;My new Dell Inspiron 1525 would be home to all my tech innovations hereafter.&lt;br /&gt;&lt;br /&gt;Being a newbie, I am going to record all my experiences with Linux, Python, Django etc. So that I keep a record of all the problems and  solutions i face and resolve. Of course the larger idea is to document my learning curve !!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7419273247922290553-583292025013383404?l=techbookmarks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techbookmarks.blogspot.com/feeds/583292025013383404/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techbookmarks.blogspot.com/2008/12/small-step.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7419273247922290553/posts/default/583292025013383404'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7419273247922290553/posts/default/583292025013383404'/><link rel='alternate' type='text/html' href='http://techbookmarks.blogspot.com/2008/12/small-step.html' title='A small step.'/><author><name>serendipity</name><uri>http://www.blogger.com/profile/01814313183465654189</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
