Sunrise Festival 207  written by garthy

Went to sunrise festival over the weekend with a trip up to Birmingham for Simon Lee's stag do in the middle of the festival. Much fun generally mooching about in the sun at the festival. And much fun going off-road carting and playing 5-a-side football. Although my bady really hated me after running around in the sun for half an hour. Photos of the festival are up on my Flickr site.

Firegathering 2007  written by garthy

Wicked time had at http://www.firegathering.co.uk/... Loverly small little festival. the best bit was probably the Jacuzzi! Much nakedness and fun! Photos are on my flicker site... :D

Deftones Gig  written by garthy

Went to see the Deftones last night and they quite positivly rocked! I was a rescheduled gig from a while back that I'd kinda forgottern about.

British Juggling Convention  written by garthy

Well that was a fun time got to see loads of loverly people I hadn't seen for ages. The british Juggling convention runs from the 11th of April to the 15th in Nottingham. and it generally involed juggling in a sports hall and drinking alot. Over the 5 days we got through a Litre of Vodka and a Litre of Absynth. Also Nick introduced me to a wicked drink... Red Bull, Vodka and Absynth. It's loverly and quite deadly.

Window Home Server  written by garthy

Ohh! Just got accepted for a beta test of Windows Home Server. Looks like fun. :D

Nine inch Not  written by garthy

Was ment to go and see the Nine Inch Nails on Monday for Reedies birthday But around 5ish got an automated call telling us it had been cancelled! Apparently """Nine Inch Nails were forced to cancel their show last night at Birmingham's Academy after vocalist Trent Reznor was advised not to sing."" Humph :(

Flickr is fun  written by garthy

I was playing around with a gallery thingy for django but then found flickr. Bit behind the times me! For $24 a year (Which works out to just a few of our british pounds) I can upload an infininte amout of photos. I have around 8GB of photos documenting my life from around 2002 when I got my first digital camera to now. I'm not a very good photographer. I'm of the take loads an maybe one will be ok school of photography. But most of them capture the general feel of the events. Loads of clubbing and sitting around in fields spinning poi.

Accidentally deleting all the comments  written by garthy

Oops! It seems I've deleted all the comments on my website! Doesn't really matter as there is noting much of value here but I guess I should explain it to myself for later reference. I ran a Django command to clear don the db tables for one of my apps. (Don't do this I guess) manage.py sqlreset app1 | mysql This should have cleared down the database tables for the applicaiton app1. But because app1 also has a refrence to the free comments models it clears all the comments too! It's my fault really and I should have checked the SQL getting executed. Ah well you live and learn etc...

Solving Django login problems  written by garthy

I was getting Django Login Problems with the login screen returning a 403 with the error mentioning about cross site scriptiing. I had a quite look for this on the Djano and it has some Cross Site Request Forgery protection middleware. Looking at my settings it was in the wrong place in the middleware list. Moving it to before the session middleware fixed it.

Birthday Synergy  written by garthy

Went to The Synergy Project at SeOne on the 9th of Feb for my London Birthday celebrations. Didn't start to well as I can down with a nasty cold on the thursday. :( Still made it up to London on the train with mike and stocked up before hand with many tissues. Generally Wicked night with much fun had although I did fall asleep for a bit of it.

Guilford Party  written by garthy

When to a wicked house party on the 16th in Guilford which was much fun. What was even better was I saw a band in a small pub that Rocked! They are can be found at Myspace

Spam Protection  written by garthy

Hmm.. Who would have though it was worth Spamming My comments section! Well someone did and filled them up with offers of casinos and viagra! Luckly it seems it's eassy to add spam protection to Django :D Spam protection for Django

Birthday Bingo  written by garthy

Went out and Played Bingo for Emmas Birthday on the 31st of Jan. It was quite a suprising experience. the games seem to get faster and faster and there's not time for anything during a game but concentration. Seeing as Gordon won £100 it was a good night. Going to Joe Public was much fun after Bingo although there was some sorta bouncer confusion at the door with my hip flask of Absynthe but he let me in (Thats's the bit I'm confused about). So Bingo, Fun to try once but don't think I'm going back.

Email notification for Django comments  written by garthy

Within Django there is a really flexable comments system that allows comments on any item on your site. And example of how to set it up is on the Django Wiki I wanted a way to notify the author by email of any new comments on an opject they had created. Below is some code that achives this. from django.dispatch import dispatcher from django.db.models import signals from django.template import Context, loader, Template, TemplateDoesNotExist from django.core.mail import send_mail from django.contrib.comments.models import Comment, FreeComment notifiyers = [] def comment_notification(themodelclass, subject_template='comments/subject_template.txt', body_template='comments/body_template.txt', user_attribute='', from_email=None, to_email=None, ): print "comment_notification" global notifiyers def send_comment_by_mail(instance): print "send_comment_by_mail" comment = instance if comment.content_type.model_class() != themodelclass: return theobject = themodelclass.objects.get(id__exact = comment.object_id) try: subject_tmp = loader.get_template(subject_template) except TemplateDoesNotExist: subject_tmp = Template('New comment for "{{ theobject }}" by "{{ comment.person_name }}"') try: body_tmp = loader.get_template(body_template) except TemplateDoesNotExist: body_tmp = Template('{{ comment.comment }}') ctx = Context({'object': theobject, 'comment': comment}) subject = subject_tmp.render(ctx).strip().decode('utf-8') body = body_tmp.render(ctx).decode('utf-8') if user_attribute: user = getattr(theobject,user_attribute) user.email_user(subject, body) else: # Maybe make it fail? send_mail(subject, body, from_email, to_email, fail_silently=False) notifiyers.append(send_comment_by_mail) dispatcher.connect(send_comment_by_mail, sender = FreeComment, signal = signals.post_save) It uses Django signals which you can hook into and run an action you desire. If you copy the code above into a file, I call it util.py, and then import the function comment_notification into your model file that you have comments associated with. If your model has a author = models.ForeignKey(User) field you can simply call the funtion passing inthe model and the name of the foreign key field. from django.db import models from django.contrib.auth.models import User from util import comment_notification from django.contrib.comments.models import FreeComment class Post(models.Model): title = models.CharField(maxlength=200) comments = models.GenericRelation(FreeComment) author = models.ForeignKey(User) comment_notification(Post,'author')

This will then send a email to the author notifying them of any comments on a Post object. There is a strange bit of the code where we add the funciton objec to the global "notifiyers" list. This is because the dispatcher.connect only adds a weak refreence to the python object and when the funciton scope ends the function object is destroyed.

The code can also cope with objects that don't have authors. In this case you have to speicify at runtime the email recipitiant. In this case people can comment on my Magnolia Links. These don't have a User Field (Although I'm considering adding it...) so I just wanna get notified when someone comments on a link.

comment_notification(MagnoliaBookMark, from_email='garth@example.com', to_email=['garth@example.com'], )

Django and ma.gnolia.com Intergration  written by garthy

If you go to the links page you'll see it's somewhat improved. I've itergrated it with the social bookmarking site ma.gnolia.com. They have a public API that allows me to query there site and fetch my list of bookmarks. These include tags and a screen shot of the site.
This was all coded by me in about 2 hours using This python module and intergrating it with the Django database.
One of the nice thigs about Django is the URL system which allowed me to replace the old weblinks app with a new shiney ma.gnolia.com app at the same url.
I'm hoping to improve the links section to add a tag cloud so the links can be filtered and maybe a search.

I'm never drinking again  written by garthy

Urgh! Had a wicked birthay! Thanks to all that came. Much drinkng cocktails on friday at Hush followed by so sorta Croft Event. then on Sat met up at the Llandoger Trow feeling decidly worse for wear after friday. Manged to pull through with more drinking and went on to dance our socks off at TimBuk2.

National Hugging Day   written by garthy

Aparently My brithday falls on National Hugging Day Loads of other stuff also happened on The 21st of Jan Including

30th Birthday  written by garthy

It would seem I'm getting old. The general plan is go out and get very very drunk in Bristol on 19th/20th of Jan. I'm also going to shake my funky stuff at The Synergy Project on the 9th of Feb Some come and join me on one or the other. :D

Nameservers moved  written by garthy

I've moved my nameservers for garthy.com over to my hosting http://www.webfaction.com This went fairly smothly but email went up the spout due to 123-reg.co.uk email forwarding being picky. I forwarded everything to my garthy.webfactional.com address and it seemed to be fine.

Poi card game posted on wiki  written by garthy

I've posted a poi card game on the wiki. If you don't spin poi go to homeofpoi to find out what the hell it is.

RSS feeds  written by garthy

The site now has a RSS feeds for your syndication pleasure. Took about 10 mins with the loverly Django framwork. Mmm... RSS feeds...

New Style  written by garthy

The site has just recived a new style. I've also made some changes to the code on the backend to make changing style less painful next time I get a bit fickle. I got the style from http://www.styleshout.com/

Little Flags by your comments  written by garthy

I've added a little country flag next to the commenters name from the country there IP address came from. This is documented here

Wiki With History  written by garthy

Knocked up a wiki with revision history and editiing capabilites. Will upload it to my site tonight and maybe release the code if anyone cares.

New Year Resolution  written by garthy

I'm going to try to keep trak of stuff I do on here. This is mainly for my own good so I can remember what I did in my life. I reckon I'll be slack. but Who knows.

First post on my new web server  written by garthy

Well this is it... My first post on my new web server!