This Week in Web – Django, Cloud9, Orion, AOP

January 12th, 2011 / By logan / No comments

CSS Overlay in Webkit

Guillermo Rauch has written a tutorial on how to implement a lightbox using pure CSS3. He gives reasons as to why using the CSS3 method is less buggier than the old javascript or “pure css” implementations and then demonstrates how to code a lightbox with animations.

Deploying Django Applications with nginx and uwsgi

Martin Rusev has written a tutorial describing how to deploy a Django web application using nginx and uwsgi. It covers compiling nginx, setting up upstart, creating the wsgi.py file for Django, installing uwsgi and configuring nginx to use uwsgi with Django. This is definitely worth reading and bookmarking if your new to Django deployments.

Hosted Cloud9

The Cloud9 team have started the private beta for the hosted version of the Cloud9 IDE. If you want to participate in the beta, create an account, and wait until your account is activated (it could be days/weeks). You can still download and host your own version of the software, but the hosted version allows you to:

  • Run and debug NodeJS applications on their cloud infrastructure
  • One click forking of GitHub projects
  • Push and pull from and to GitHub
  • Access your code

Tutorial: Django Template Tags

January 10th, 2011 / By logan / No comments

Introduction

In the Python Web Framework Django, template tags can be used to modify data that is about to be output in a Django template file. In this tutorial we will learn how to create and use our own template tags in a Django application.

Setting Up

Template tag definitions are stored in Django apps. The template tags in each app should be relevant to the models and views in that app. You shouldn’t have one app that stores every single template tag you use throughout your website. Each app can contain a directory called templatetags and assuming the app is added to settings.INSTALLED_APPS, Django will automatically search that appname/templatetags/ directory for template tag definitions. Remember to put an __init__.py file in each templatetags directory because the template tags inside them are imported.

Example

In an application I worked on recently I needed to display some data about a World Of Warcraft character such as their race, class and gender. The information about the character was stored in a database table and was referenced like so:

This means that if the character was a Male Orc Shaman, then the…

This Week in Web – jQuery, NodeJS, FuelPHP, How I Work

January 7th, 2011 / By logan / No comments

5 Things You Might Not Know About jQuery

David Flanagan has written a post a post at O’Reilly titled ’5 Things You Might Not Know about jQuery’. As the name suggests, the post discusses 5 tips, tricks and shortcuts about jQuery. If you taught yourself jQuery by referencing the API, then these tips are probably useful. However if you read a book to learn jQuery, chances are these tips would have been covered in that.

Serverside JS Tools

Addy Osmani has written an article about different libraries that can be used when developing NodeJS applications. If you are new to the NodeJS community I recommend you read this article. Osmani covers:

FuelPHP

FuelPHP is a new PHP framework which aims to be light, fast and full featured. It is primarily based on the Kohana Framework but draws inspiration from Code Igniter. Fuel comes with it’s own ActiveRecord implementation as well as support for database migrations. The core library is fully namespaced (for some reason the application you create doesn’t…

Interacting with Skype from Python using Skype4Py

January 3rd, 2011 / By logan / No comments

Skype4Py is a Python module that allows developers to programatically interact with the Skype client running on their computer. In this tutorial we will look at and use the Skype4Py module to create simple but useful scripts.

Installation

Skype4Py is a normal Python module and is listed in the Python package index (Pypi). To install it with setuptools enter the following in a command prompt.

easy_install Skype4Py

To install it with pip enter the following in a command prompt.

pip install Skype4Py

Getting Started

Skype4Py interacts with the Skype client running on your desktop, it doesn’t talk directly to the Skype servers. For any of the scripts we cover in this tutorial to work the Skype application must be running and you need to be logged in. You can either start Skype yourself or use the following snippet to start it using Skype4Py.

s = Skype4Py.Skype()

if not s.Client.IsRunning:
	s.Client.Start()

Before we can interact with the Skype client from Skype2Py, we need to connect Skype4Py to the instance of Skype running on your desktop. This is done using the Attach method.

import Skype4Py

s = Skype4Py.Skype()
s.Attach()

After executing this you need to check the Skype client on…

This Week in Web – Python, KodApp, jQuery

December 31st, 2010 / By logan / No comments

Easy PyGTK For Windows

The PyGTK project has released an all-in-one installer for Windows. This gives people developing PyGTK applications on Windows a quick and easy way to install all required dependencies. The bundle can install the GTK runtime, PyGTK and the Glade GTK GUI Designer. Prior to this developers would need to install each component separately which was often difficult due to version clashes. PyGTK can be used to create cross platform GUI applications using the Python programming language.

KodApp

KodApp is a new code editor for Mac OSX 10.6+. Although still in early development, creator Rasmus Andersson has done an amazing job of putting together a fast, stylish editor that is sure to challenge the likes of Textmate. The Google Chrome like tabs are achieved through Andersson’s chome-tabs library, which is native Cocoa. KodApp is open source on Github and you can keep up to date with the project with the mailing list.

Common Mistakes as a Python Web Developer

Armin Ronacher, creator of the Flask web framework has published a blog post detailing common mistakes Python web developers commonly make. In the post Ronacher talks about path inclusion vulnerabilities, escaping…

Book Review: PHP5 CMS Framework Development

December 27th, 2010 / By logan / No comments

PHP5 CMS Framework Development is a 322 page book that covers all aspects of creating a full featured content management system (CMS) in PHP5. The author Martin Brampton has a history of developing extensions for the Mambo and Joomla CMS projects. He became lead developer of the CMS Mambo before starting his own CMS, Aliro. The book is split up into 14 chapters. The first is an introduction to CMS and PHP5 concepts and the remaining 13 each look at a key feature of the CMS.

The book starts by defining what a content management system is and what features it needs to have. It then gives some background into the Model View Controller and Object Relational concepts as well as the Factory, Singleton, Observer and Command design patterns. If you haven’t used a CMS before and don’t know PHP5 OOP, this chapter prepares you excellently for the rest of the book.

The remaining 13 chapters each cover a feature of the framework. This includes:

  • Database abstraction
  • Access control, user authentication
  • Framework extensions/plugins
  • Caching
  • Internationalization
  • Error handling
  • Menus

Brampton has done a great job at explaining each feature before he shows any code. This ensures…

This Week in Web – Doctrine, JS Game Engines, Firefox4

December 24th, 2010 / By logan / No comments

JS Game Engines – ImpactJS and CraftyJS

ImpactJS is an HTML5 game engine that targets all modern browsers as well as the iOS platform. Although it costs $99, ImpactJS comes with amazing documentation and a level editor/designer called Weltmeister. Weltmeister allows you to design your terrain, layers and game entities (sprites) in an easy drag and drop fashion. If $99 is too much to pay for a library then you may want to look at CraftyJS. It is a free and open source (MIT, GPL) game engine which includes support for isometric maps.

DjangoWeek.ly

DjangoWeek.ly is a Django newsletter, organized and run by Jon Atkinson. The newsletter will cover all Django related news, articles and applications. The first newsletter is due to be sent out during the first week of January so subscribe now. It is sent out by MailChimp, so you can be sure your email won’t receive spam.

Drupal 7 Release Date Announced

The Drupal Project has announced that Drupal 7 will be released on January 5th 2011. There will also be numerous release parties throughout the world. Make sure to check the release party website to see if there is…

Writing a module for Kohana3

December 20th, 2010 / By logan / No comments

In this tutorial we will cover how to build a module from scratch in Kohana 3. If you aren’t familiar with the Kohana framework then I recommend you read the beginners introduction to Kohana.

The Plan

We will be building a module that replaces Kohana’s own view layer (Kohana_View). It will use the PHP template library Twig. We want our own view layer to be API compatible with Kohana’s view layer. This will ensure that other modules work out of the box and that the only code the developer will need to alter in their application are the templates (so that they are Twig compatible). No code in any controller will need to be modified.

Because Kohana follows HMVC (see beginners introduction to Kohana) we will be calling our class View. This means that all calls in the application to the class of View will be to the View class in our module, not Kohana’s own View class.

Directory Structure

Enabling The Module

The name of any Kohana module is the same name as the directory inside the modules directory. So in this case it is twig. To activate any module, we must add it…

This Week in Web – App Engine, Lanyrd and PHP

December 17th, 2010 / By logan / No comments

App Engine 1.4.0

Two big changes in the latest Google App Engine release have been the new Channel API and the new 10 minute limit for background processing with a new Task Queue API. Both of these have been highly requested features for some time.

The Channel API creates a persistent connection between your application and Google servers, allowing your application to send messages to JavaScript clients in real time without the use of polling. This is useful for applications designed to update users about new information immediately. – Google

Expect to see the Channel API used for chat applications and real time games. The new Task Queue API allows developers to easily set up long running task jobs. Prior to GAE 1.4.0, scripts could run for a maximum of 30 seconds before they were terminated. Now scripts (using the Task Queue API) can run for a maximum of 10 minutes so data manipulations will be able to be performed on App Engine rather than on an external server.

PHP Maintenance Release

PHP 5.3.4 and 5.2.15 are now available. Both contain numerous bug and security fixes from their previous versions. Support for the 5.2 line is…

An Introduction to Kohana3 PHP Framework

December 12th, 2010 / By logan / No comments

This is a brief introduction into the Kohana framework. The next two tutorials will cover how to build a blog in Kohana.

Installation

Installing Kohana is very straight forward, just download the latest stable version of Kohana and unzip it. No need to mess around with yaml or xml files like other frameworks. Navigating to the directory on your web server should give you a page similar to…

Filesystem

The filesystem plays a big part in the operation of the Kohana framework. Kohana follows the HMVC pattern (hierarchical model view controller). This means that the same filesystem structure exists at multiple locations in the framework. The following directories exist in the application, system and in all module directories:

  • classes
  • config
  • i18n
  • messages
  • tests

When calling a class in Kohana, the autoloader checks if the class exists first in application/classes/ , then in each of the installed modules, classes subdirectory and finally in system/classes/. If the file cannot be found then an exception is thrown. Kohana follows the Zend_Class_Naming style. For example, if you instantiated a class named Hello_World, Kohana would look at each of the following locations in this order. If it finds that…