Django File Upload Handling Examples

February 18th, 2009

I have been working on a multi-user blogging and publishing platform using Django 1.0 lately. Naturally this requires the backend to be able to handle file uploads. A lot of things have changed from Django 0.96 which I am still using on some legacy code. One of those changes is the way Django 1.0 handles file uploads. Most of the changes done were made to allow Django apps to handle large files without soaking up too much memory.

So what has changed? The most visible change is that there are now at least two separate API’s that you have to work with. You have the File API and the Storage API. The File API which exposes the File class provides a thin wrapper around Python file objects. The Storage API, on the other hand, exposes a base class Storage that you can use to implement custom storage facilities. There is another API that provides FileUploadHandler. This will allow you to customize the way Django handles the uploaded files in their “raw” form. For most purposes, the File and Storage API will suffice.

This post is meant to supplement the information found in the “Handling Uploaded Files” section of the Django File Uploads documentation. You will still need to refer to documentation.

Read the rest of this entry »

Hectic Capiznon Bloggers

February 8th, 2009

If you came here via Google Search for the keywords “Hectic Capiznon Bloggers” then this rant is for you. Let me guess, you are part of this “SEO Contest” to push this particular set of keywords up in search result rankings. Think about what you are doing for a second. Do one better and ask yourself, “What am I doing? Is this SEO or is this spam?”

What is SEO? SEO stands for Search Engine Optimization. What it all boils down to is that you use optimization techniques so that your website shows up first in the search results when someone searches for a particular keyword using Google or Yahoo search. It is a legitimate practice that is not only allowed, it is also encouraged. Google engineers like Matt Cutts encourage good Search Engine Optimization techniques and practices because it makes Google Search better at providing people with relevant search results. The problem lies in some shady “SEO techniques” that subvert the system.

Personally I have no problem with SEO and SEO Contests in general. I have used “white hat” Search Engine Optimization techniques when building CMS-enabled websites. The new Django-based multi-user blog and content publishing platform I am working on has features geared specifically towards SEO. However, I do have a gripe against people who use shady practices for “SEO”. Practices such as link bombing, keyword stuffing, spamdexing, content scraping, and cloaking are not only bad form, they are harmful.

Most SEO Contests I have seen used a set of intentionally nonsensical keywords. The organizers of events who use nonsense keywords such as “Nigritude Ultramarine” and “Seraphim Proudleduck” understand that the actions of their contestants have the potential to pollute search engine indexes. There are some organizers who fail to grasp the importance of keeping search engine indexes free from bogus search results and intentionally use valid, and sometimes commonly searched, keywords for these contests.

“SEO Contests” which use valid keywords like this one for Hectic Capiznon Bloggers are particularly bad. I am not sure if the organizers of this event know it but the following keywords will also match “capiznon”, “hectic blogger”, “capiznon blogger”, “capiznon blog”, “capiznon blogger”, “hectic capiznon” and a few other permutations. From what little information that I have found on this particular contest, there does not appear to be any set of rules as to what SEO techniques are allowed/disallowed (if there are, please point them out in the comments). So what is stopping the participants of this contest from using bad “SEO” practices?

Again I must stress: I have nothing against SEO and SEO Contests in general. But contests like this “Hectic Capiznon Bloggers” Contest pollute search engine results with bogus sites with no useful content on them whatsoever. For example. Search for the keyword “Capiznon” on Google. You will get only 1 relevant search result and it points to a Wikipedia entry. Capiznon is a valid keyword and it is something someone would enter if they were looking for information about the Capiznon Language. Instead of useful information about our cute little variant of Hiligaynon, you will get two pages full of irrelevant search results all pointing to this SEO contest. I will say it outright: You have just spammed the entire world with your nonsense! You have diluted the value of the word “Capiznon” with all this gibberish about a contest that no one really cares about.

Piece of advice to anyone who wants to start yet another SEO Contest: DO NOT USE VALID KEYWORDS IN YOUR CONTEST!

NOTE: The following paragraph has been reworded to make my point clear.

Piece of advice to people (especially the students) who join these contests: take a look at what the contest requires you to do. Review the rules and requirements carefully. There have been contests in the past that required one or more of the following from the contestants:

  • Link back to several websites. One or two link backs are not bad. They are a powerful promotional tool. For example Animax Lamb used this to promote their website. On the other hand, link farming is a questionable activity.

  • Contestants are required to “sign-off” their domain/blog/website. Now this requirement is fishy. If the contest requires you to transfer ownership of your domain/blog/website or content to the organizers walk away (unless there is at least a 5 figure sum involved ;) ). Your domain/blog/website should be yours and yours alone and if they want it for themselves, you should make them pay through their noses instead of handing it over to them because of some sneaky contest rules.

Update

Note to those who wish to comment: Before you post a comment, please read the first three comments below. This is a conversation between Mr. Duane Cartujano (the organizer of “Hectic Capiznon Bloggers” SEO Contest) and myself. This post is mainly a critique on the way the contest was set up and not on SEO and SEO Contests in general. It is meant to serve as a guide on “How NOT to Do an SEO Contest”. As you can see, Mr. Cartujano has been professional enough to respond with tact to my criticism, even soliciting me for advice on the subject.

I have allowed some disrespectful comments (most probably by one of the contestants) against me. But this is only because I wanted to clarify my position regarding SEO and SEO Contests. This is my personal blog. I can pretty much say whatever I want to say here, but you cannot. So if you wish to leave a comment, please do so in a courteous and professional manner. Any more disrespectful and unprofessional comments will be deleted.

On “SEO” for this blog. It has very little SEO applied to it, only as much as you can get with a default Wordpress installation and this is by intent. The reason is that this is a “disposable” domain name. I might let go of this domain name in the future and I do not want it to have a high Google PR.

Thanks for stopping by.

Why Do People “Pirate” Music and Movies?

January 12th, 2009

Now that all the hullabaloo from this year’s Macworld Expo had died down a bit, I decided to check out one of this year’s headlines: DRM-Free iTunes Music and Videos. Regardless of all the ill-tempered rants against DRM, I still bought “encumbered” music from iTunes in the past two years. So it was great news that Apple has finally succeeded in getting most of its songs in DRM-free format. The fact that you can “upgrade” your previous purchases to the DRM-free format is good news as well. But as with everything good in this world, there has to be some sort of catch. The catch is that if you want to “upgrade” your previously purchased you have to pay an additional $0.30.

Right, so I already paid $0.99 to download the DRM-protected, 128Kbps format. If I want to “upgrade” to the DRM-free, 256Kbps format, they want me to pay them another $0.30. WTF?!? So they doubled the bit rate and removed the DRM. That’s just great. 99% of their customers (myself included) will not be able to tell the difference between 128Kbps and 256Kbps bit rates, but that must make that 1% really happy.

See, now this is why people “pirate” all your shit. You want us to pay for one copy in one format and you want us to pay for another copy of the same thing in another format. But ooohhh! It’s 256Kbps and look at the slick GUI! I’m probably going to pay to get my albums “upgraded” anyway so why the hell am I whining? See you all on “the bay”.

AXN Beyond (aka TV Series Graveyard)

January 3rd, 2009

Our local cable TV company got a new channel a while back. AXN Beyond, or as I like to call it: “TV Series Graveyard”. Nothing on it but old TV series reruns. What is it with TV networks? They give you a good TV series every now and then. It hooks you in and just when you are starting to enjoy it, they ruin it by either dragging the series so long or kill it outright. Either way sucks. Dragging on a good story for too long before ending it eventually makes it boring. Ending a good story just when it was starting to pick up makes for a very disappointing finish.

I think I now understand the wisdom in Disney’s 64 episode limit. Most Disney series will end within 64 episodes or less. A few will get dragged on for 100 or more episodes but it’s rare to see a Disney show drag on for more than 3 seasons.

Read the rest of this entry »