Linode apache mod_wsgi django setup for future reference

My django server setup for future reference, because it’s too easy to forget exactly who’s talking to what file in 2 months.
Will put nginx front end proxy soon.
  • Apache listens on port 80
  • Port 80 is a VHOST in sites-available / apache2.conf
  • Apache Vhost points to WSGI Script in /srv/anuva/_project/apache/django.wsgi
  • WSGI Script adds anuva project to PYTHONPATH
  • WSGI Script defines which  anuva.settings as project, and django’s WSGIHandler processes the request.
  • Apache displays request.

Things I’ve done this time for better management:

The project itself is now in a folder called anuva_project, alongside a logs folder, and apache folder.

I can now add all project specific things in one folder instead of everywhere. Logs are easily accessible instead of at /var/log/apache2/site .

I can add a directory for site specific python packages by adding the directory to the pythonpath in the WSGI script.

Gmail — Open attachments right away, skip virus scan or other bugs

Gmail always gives me trouble when trying to download an attachment. Just now, I couldn’t download my attachment for no reason. There was no error message, it just wouldn’t make a download button.

If you want to skip it, pretend you’re forwarding the message and the attachment will appear as an attachment that you can just click to reliably download it.

JavaScript — Accessing functions defined in jQuery scope / ReferenceError setInterval

To trigger a function defined in your document.ready function, you need to define a variable before the $(document).ready() that references the new function.

For example, function test() defined inside $(document).ready() is not accessible with setInterval('test()', 500), or something like onclick="javascript:test()"

$(document).ready( function() {
function test() { alert('test'); }
setInterval("test()", 500);
});

Will fail with ReferenceError

The following will work though:

var test;
$(document).ready( function() {
test = function() { alert('test'); };
setInterval("test()", 500);
});

Will work.

Fantastic writeup of Anuva Wines on ArgentinasTravel.com

Jon masterfully captures the essence of the private wine tastings, all the way from his initial skepticism to his overwhelming support.

…this is a family business, and not a faceless corporation. I’ve been to those large tastings where you, like a bottle in the assembly line, are pushed in and out so quickly that you don’t even have time to ask what you just drank.

http://argentinastravel.com/4474/anuva-wines-a-special-introduction-to-argentinean-wine/

Let me know what you think!

Python — Quickly Debug a Variable Value

raise Exception, “an error message string”
Will raise an exception and print the string.

raise Exception, str(my_variable)

raise Exception, str(myDictionary)

raise Exception, ” %s %s %s” % (v1, v2, v3)

Reviews of Anuva Wine Tastings in Buenos Aires

I thought I should share a few great write-ups of Anuva Wine Tastings in BA written recently.

Travel Writer Jon Brandt has great things to say about a wine tasting he attended last weekend

http://ttravelguy.blogspot.com/2010/04/wine-tasting-with-anuva-wines.html

“I’ve been to wine tastings before in Sicily and in Mendoza, but this was different. Rather than being rushed through a distillery with a guide who doesn’t fully reach fluent status, we were in Karlin’s home, and we were quickly made to feel like old pals.

Karlin is actually an American expat, so aside from his perfect English, he had a different perspective to give us for restaurants, politics, and culture. This isn’t a lesson that should be taken for granted, and to be honest I think it’s one of the best and most distinguishing qualities of this experience.”

San Telmo Loft had a similar experience, with great pictures and write ups of each wine served.

http://santelmoloft.com/2010/03/26/anuva-wine-tasting/

“He wanted to be reassured that the wine tasting was going to be run by professionals who would not only pour from bottles but be able to answer his questions and guide him to the must-visit bodegas (wineries) on his trip to Mendoza.

We decided to call the various places. Several places were not able to answer our questions at all. In essence, you go there, pay to taste the wines, and have zero guidance or discussion about what you are tasting and why these wines were chosen. Also, we didn’t want a full dinner with the wine tasting. We really wanted to focus on the wines. Paired with the appropriate foods, yes, but not a full meal.

Sarah, the Tasting Room Director at Anuva Wines, answered the phone. She answered all of Andy’s questions and showed such knowledge and professionalism that we knew Anuva was the place.”

I’m glad to read that both appreciated the wines, the wine knowledge, and personal service.

If you’re visiting  Buenos Aires any time soon, consider booking a tasting early in your trip,  because we’ll be sure to recommend nearby restaurants, activities, and answer any questions you might have during your stay.

https://www.anuvawines.com/wine-tastings/visiting-buenos-aires/book/

For more reviews, visit TripAdvisor

http://www.tripadvisor.com/Attraction_Review-g312741-d1475622-Reviews-Anuva_Wines-Buenos_Aires_Capital_Federal_District.html

Django to PHP

First few days on PHP from django. No I am not switching. I will definitely use django for projects built from the ground up, and I will probably use PHP for really simple stuff.


I like how easy its going to be to extend stuff like WordPress to fit the needs of casual sites that don’t need a monster built from scratch.

Good GOD it’s at least a hundred times easier to learn this after programming experience. The first time you have to learn it from the backend to the front end. PHP would have been so much easier to learn than django with no prior server experience. At least it’s as simple as FTPing a freakin file for most providers.

With django, the programming itself is well documented, but you have to learn a little bit about what’s normally split into at least 3 or 4 other jobs titles to run your own server.

Also, not having a database abstraction layer is pretty awesome in a sense. Django’s ORM didn’t require me to use much raw SQL, so.. I was spoiled. Dealing with PHP will force me to learn SQL, which is a good thing.

Php? Plop down a file in FTP. Wow that’s easy.

PHP — Log Arbitrary Stuff to File

Reminder: I’m brand new at PHP. I’ve been told it’s the devil, but I’m liking it so far.


Anyways, logging random stuff to file:

class logfile {
function write($the_string) {
if ( $fh = @fopen("/home/clubarge/static.anuvawines.com/wp/wp-content/logfile.txt", "a+"))  {
$the_string .= '\r\n';
fputs( $fh, $the_string, strlen($the_string));
fclose( $fh );
return (true);
}
}
}
// write to the log
$lf = new logfile();
$lf->write("LOG ME");
Fantastic! Now you can see what's breaking in your code by logging variables as you see fit.  $lf->write($myvar);