Pigwideon Geek

Maintaining and Open Relationship with Google

Google's mission is to "Organize the World's Information" and they do a rather smashing job of it as long as they alone are doing it.   Even though they do a better job than most as staying open, there is still a significant risk when putting all your eggs in the Google basket and few options for backing out.   Particularly with the rise of Google+, Google Music beta and other such services going all in on Google could prove a big liability for individuals and companies in terms of being able to shift to new or better services as they emerge or just re-establish ownership over your own content.  Every business would do well to act with caution in opting for the convenience of any service as that convenience would too easily transform into abducting the ownership of your content.   I would suggest that losing control of your content in a world where ideas and content are a commodity is the same as losing control of your life or business.

With a little forethought however some convenient ways exist to both leverage the convenient services offered by Google and remain managers of your information.  The Digital Liberation Foundation launched it's "Google Takeout" service, that allows the harvesting and export of your information from various Google services into open formats.  Open formats are the key to keeping your content flexible and mobile and in a world where 5 years is an entire era of information management practices, this is critical to surviving and thriving in the modern world.  The group is starting with export features related to Google services but plan to expand their ability to other services as well.  I assume (hope) this means Facebook and Yahoo! based services but only time will tell.

Even with groups like this helping to keep information open and portable a healthy dose of caution is advised when flirting with services providers like Google.  Grass-roots efforts are fragile at best and ultimately the pressure needs to be on the big companies to keep their standards open.  A world that encourages the generation of ideas and helps communities evolve is what will bring the kind of innovation we're all seeking and like it or not our practices and the good faith of major corporations are going to heavily influence our success at this. 

Crossposted from Flagon with the Dragon

Pigwideon Geek

Rise of the Apes Trailer

There's a new trailer out for the Planet of the Apes reboot called "Rise of the Apes" and it really looks fantastic.    It's amazing how much story they can convey in a simple trailer and I have hopes the movie has a lot of depth in it.  There seems to be a lot of potential for commentary about the nature of intelligence and self, the respect for life and compassion or what a lack of it brings.  Seeing the "acting" of Caesar with the John Lithgow character, who seems to have Alzheimer, brought a tear to my eye as you watch the chimp express compassion for the human who is obviously struggling.    This could be the start of a great movie franchise, at least I hope it is.


Crossposted from Flagon with the Dragon


Pigwideon Geek

Random Library Art

One of the patrons in our library left this drawing up on one of the writable wall space.

From Just Life

It's a great piece really and in particular the proportions are very good on the figure, it manages to convey a sense of perspective for such a simple drawing.

The saddest part of the whole thing though is the red line across the chest.  Seems like this was just a simple sketch of a girl sitting by a tree but someone was so threatened by breasts that they had to erase them and draw that red line across the space.  Perhaps that was part of the original art and a statement but I kind of doubt it. Sad really.

Originally Posted on Flagon with the Dragon

Pigwideon Geek

Wordpress to Django: Strategies Dealing with Wordpress Querystring URLs

Stable URLs are the foundation of valuable information on the web.  As Tim Berners-Lee eloquently described it "Cool URIs Don't Change" and I thought I'd address a few strategies and code I'm using in MetaRho for maintaining stable URLs for content migrating from Wordpress.

Wordpress Querystring URLs

By default Wordpress uses querystrings for accessing content, passing the internal ID number of the post through the 'p' attribute like so...

http://<domain name>/index.php?p=<post id>

So for example calling post id 1 on mydomain.com would look like.


Since best practice for Cool URIs and in Django is to use real URLs instead of Querystrings this presents a small problem.  The easiest solution I found is to simply implement a decorator in Django that I put on the default index view to watch for incoming WordPress querystring URLs and query some extra field on the model for blog posts that holds the original WordPress ID number.  Note I do NOT try to maintain ID numbers between posts as the better practice is to keep these opaque from the user.

I use the common strategy of keeping a one to many Model related to my posts to contain key value pairs for extra data.  In my implementation I call that Model PostMeta and when I import content I just store the original WordPress ID number under a key 'wp_post_id'.

(view code on github)

def wp_post_redirect(view_fn):
Checks a request for a querystring item matching a WordPress
post request.

This is to enables url redirects for blog migrations from WordPress.
To use just decorate the view method for your default blog location.

def decorator(request, *args, **kwargs):
wp_query = request.GET.get('p', None)
if wp_query:
post = Post.objects.published().get(postmeta__key='wp_post_id',
ar = post.pub_date.strftime("%Y/%m/%d").split('/')
htr = HttpResponseRedirect(reverse('blog:post-detail', args=ar))
htr.status_code = 301 # This should reflect a 'Moved Permanently' code.
return htr
except Post.DoesNotExist:
raise Http404
return view_fn(request, *args, **kwargs)

return decorator

The decorator is fairly simple and just queries for posts with that meta key and redirects the user to the real URL with the proper status code or issues a 404 if no post is found.

It's important to note that this decorator needs to be put on the view used at the of the blog app as that is the equivalent behavior from WordPress.

In my next update I'll discuss a bit about designing Django URLs to deal with typical WordPress URL rewrite configurations.

Originally Posted on Flagon with the Dragon

Pigwideon Geek

Game of Thrones, You Win or you Die

HBO's Game of Thrones has definitely been delivering on it's promise of expressing all the brutal politics from the books and the latest episode is probably the most pivotal of the series so far. EPISODE SPOILERS AHEAD..

Tyrion continues to be my favorite character in the series and the Emmy Awards better be thinking about putting a milk crate next to the acceptance stand this year for Peter Dinklage. It's a particular testament to his performance so far that the character's absence brought the quality of the episode down a bit.  Other than that I have few complaints with it and it's probably obvious to anyone who has seen it that the game is on now and things take an uncontrolled slide from here on out.

I continue to really enjoy Jon and Sam, their performances are fantastic as is the performance of Danny and Drogo.  I'm still fascinated to see how these storylines will hold up against the one in Kings Landing as the series progresses.  It feels like sooner or later one has to emerge in the series as the "lead" storyline and I just don't see how the series can maintain it's integrity if that happens.  It's going to take some brilliant writing and filing to keep that from happening but if they keep the level of talent they've displayed so far I think they can pull it off.

I'm loving and hating the same characters as I did in the book despite some apparent changes in how they develop so It'll be interesting to see how I feel a few seasons in.  

Good Riddance to Robert btw.  Again a great performance because the character felt exactly like he should, like he was in the way.   Now that he is gone and things have turned as they have for poor Ned I am looking forward to the reactions of my friends who haven't read the books as other characters take on more emphasis.

Good times ahead I hope and I'm looking forward to next week.

Originally Posted on Flagon with the Dragon

Pigwideon Geek

Gunshots by Computer

The Pentagon issued a much needed policy on cyber-attacks against the U.S. today, putting it in the same category as any other attack on the infrastructure.  Linked and quoting the opening below from the AFP for reference...

US 'to view major cyber attacks as acts of war

The Pentagon has adopted a new strategy that will classify major cyber attacks as acts of war, paving the way for possible military retaliation, the Wall Street Journal reported on Tuesday.

The newspaper said the Pentagon plans to unveil its first-ever strategy regarding cyber warfare next month, in part as a warning to foes that may try to sabotage the country's electricity grid, subways or pipelines.

Every nation is eventually going to have to express a policy related to cyber-warfare but this is less than half the picture.  It's not enough to just issue a policy related to acts against the country and we're going to struggle culturally with what we're ethically comfortable with in terms of launching cyber attacks.

The world breathed a collective sigh of relief when the STUXNET worm infected Iranian uranium enrichment plants, setting their nuclear program back a several years.  The mysterious originators of the virus were applauded for their innovation and service done to the world.  Following the pentagon policy however, this is an act of war and had Iran retaliated as such would they have been within their rights under international law?  That doesn't feel right of course but I think it expresses the fact that we're going to have to fully realize the implications of any policy related to cyber-attacks.

One of the great benefits of the internet and the information age is that it allows individuals or small groups to act on a scale previously reserved for governments and industry.  With trans-global groups like Anonymous acting with the power of governments this is going to get particularly difficult to enforce.  Who do you hold accountable for their acts in terms of your cyber-warfare policy?  Does a nation act against another because a large portion of Anonymous users are in a particular country?  Socially these kinds of movements aren't so different from from trans-national groups like Greenpeace or, in the worst case scenarios, terrorist organizations.

Philosophic debate aside, the first line of defense is really going to be individual IT professionals and IT shops.  Following best practices is the best defense for any shops on any scale but in a world of corner-cutting and outsourcing this generally does not rise high in the priority stack for most organizations.   Having contingency plans for backups, offline/off-site backups, offline service continuity plans and the like are all incredibly important for any organization to be able to recover after a large scale attack.  A well crafted emergency plan can be the difference between a temporary service outage and putting an organization out of business.  For Academic Libraries like my own it's particularly critical because it means the loss of potentially unique or irreplaceable information.  

A well crafted contingency plan for libraries would mean they can still function in terms of their collection on a day to day basis.  Provided servers, discovery tools and the like are able to be firewalled off from the outside world it's likely even online catalogs and digital repositories can maintain access from internal computers and systems and that most digital services can still be available on-site.  The trend in libraries of hosted and aggregated services though make us particularly vulnerable to the realities of cyber war.

Only time will tell and the early nature of these realities mean we're likely in for interesting times ahead.  Innovation and organization discipline are our only real defense.  It's our responsibility to advocate for it though and in that sense the Cyber-War began a long time ago for all of use.   Fight the good fight everyone.

Originally Posted at Flagon with the Dragon
Pigwideon Geek

Reading Site Domain into Django Templates

Original Post at FlagonWithTheDragon.com Reading Site Domain into Django Templates

There are a number of great new features in Django 1.3 for template developers.  Not the least of which is the addition of the STATIC_URL attribute in settings.py to help with referencing static media.

I found when trying to integrate social media linking in blog posts however that there wasn't a good way to pull the entire site domain into a URL without hard coding into the template.  Something that makes and descent Django developer shiver.

The easiest way around this is to use the .get_current() method of the Site model and access that via a custom template tag in your templates.  

The code itself is very simple:

from django import template

from django.contrib.sites.models import Site

register = template.Library()

def sitedomain():
    '''Returns the URL of the default site.'''
        return Site.objects.get_current().domain
    except Site.DoesNotExist:
        return None

This makes it pretty easy to call in your template. I was able to use it to forward complete URLs onto some javascript functions that provides social linking in posts.

Pigwideon Geek

The Flagon With the Dragon as the brew that is true!

I did manage to overcome the appauling inertia that's been plaguing me the last few months and get my domain switched over to my new web host. You're looking at it in all it's gory glory!

As mentioned in my previous post I've decided to move my site over to a django app and out of wordpress because I want to experiment a bit and need a probject to do that with. So I've begun the process of cleaning MetaRho up, get it minally functional and then start marching forward and adding features where it pleases me. If you're looking at it right now then the minimal thing is pretty apparent. I'll grab a screenshot of the site for posterity and hopefully to show a comparison of it in a few month.

On a side note I've switch to GitHub for my repository playground and it's amazingly impressive so far. I love you and all Mercurial, but don't like that Bitbucket dress you've been wearing. Webfaction is also turning out to be a pretty useful hosting service and so far I'd recommend it to anyone looking for a good and flexible site host.

All 2000+ of my previous blog posts are still live on a wordpress install here. I'm saving them there until I get caching working properly on this site and django-tagging integrated properly.

Right now I can basically post things and the RSS feed should work, let me know if it doesn't. Expect to see more soon.

See Original Post

Pigwideon Geek

That Code it Jingle Django Jingles

Wordpress is for sissies...

Well really it's for people with brains or a greater sense of sanity than me. I brought up the minimal code to get this site working today, just now in fact. I want to take my blog over to a Django as a play space, place to experiment, expand and all that. Either way it's just coming together and I'm doing what I can to get it running as bug free as I can so so I can start adding some actual features I might enjoy.

I've had to overcome a lot of inertia in thinking I should just do wordpress but I figure I can always port it back if I want.

Because the code is just coming together and there's no caching I don't want to import the 2000+ posts from my previous blog so that IS still being served in wordpress and you can find it here in all it's former glory.

Also I have to get my domain switched over to here, so you're seeing this today at whatever temp domain my provider gave me. At the time of this writing that is 'streamweaver.webfactional.com' but expect to see good old 'www.flagonwiththedragon.com' back poisining the bandwith soon.

Expect to hear more soon.

See Original Post