This Just-in! Justin Myles Holmes

by Justin Myles Holmes

Posts categorized “About Justin”


A rare example of “magic” and Gnosticism in Django

July 4th, 2010 at 5:57 pm

Among my personal friends, I don’t think it’s any secret that Django is currently my favorite web framework.  In particular, Django has what I believe to be the very most important element that a MVC framework can have – a solid, consistent philosophy that developers can adopt, meditate on, and integrate into their thinking as they proceed through any project.

One of the tenets of Django (albeit not a “top-level” holding like DRY, OaoO, minimal code, explicit over implicit, etc.) is that Django declines to use “Magic” unless it is overwhelmingly easier than the mundane solution that it replaces.  Django also veers toward the agnostic – meaning that one can use any naming paradigm, template strategy, URL convention, etc.

Exactly what techniques constitute “Magic” may be in the eye of the beholder, but generally we think of magic encompassing those techniques that are not part of a programming paradigm, but that work anyway “just because.”  Gnosticism, on the other hand, is pretty obvious when it rears itself: If you MUST use jQuery or you MUST name every variable drupal.something, you know that you are not working with an agnostic framework.

The SlashRoot team is currently working on a great project for Carbon Ads – a project that aims to enable small publishers to collectively sell ad space to pre-vetted, exclusive, and otherwise unattainable advertisers.  Think Adsense meets your favorite organic co-op.

Among the interesting elements to tackle in Django, as is often challenging in MVC frameworks, in the question of how to model different types of users.

The lazy (inorganic) way, of course, is to simply apply a “type” attribute to the user model and then ForeignKey each individual user class.  However, this leaves tremendous room for error.  For example (and this example in fact has come up in this project) – what if the developer creating the “admin” model has a different idea of how to track names than the developer creating the “publisher” model – may one of them thinks that the full name belongs in a single field while the other separates first and last names.  This is a major problem for any page that lists all users by real name.

To me, the most organic solution is to separate elements into two categories: Those that two or more classes of people have vs. those that only one class of people has.  That way, the attributes in the former category can be assigned to a parent class (perhaps as an optional field) while the latter can belong exclusively in a child class, on a separate database table to enhance performance.

So, how does Django treat this contingency?  With magic, I’m afraid.

The Django documentation on this point suggests using the “lower case” name of the class in question, which has two deviations from the general Django philosophy:

1) It is gnostic, plain and simple.  It assumes that you have adopted upper-case or CamelCase naming conventions for your models, and that you can use lowercase as an alternative.

2) It seems to me to be magic.  There is no *reason* why the lower-case class name should refer to the logical question of whether or not an object is in a child class of a parent model.  It just…. works.

Mind you, I can deal with both these issues.  I think that the “magic” issue is of more concern to the programming purist, because it can be genuinely confusing.  Case in point, I actually had to wonder how to access the “not magic” of this solution – although “if not someobject.somelowercaseclass” does in fact return TRUE for objects outside the child class in question, it took me some time to wrap my head around this, simply because “someobject.somelowercaseclass” is not instinctively a logical value to me – the “magic” distracted my view for a moment.

Thus, I had this interesting (and perhaps telling, I think) exchange in #django:

<jMyles> Philosophical question:  Does the ability to ask for a child class with lower-case lettering represent “magic”?  (see: http://docs.djangoproject.com/en/dev/topics/db/models/#id7)
<jMyles> To rephrase my question: Is the use of a lowercase letter to inquire about a child-class part of an established programming technique?  Or is it a (rare) example of magic in Django?
<igloo_x> jMyles> what do you mean “child class”
<jMyles> igloo_x: Actually I mean child model
<jMyles> igloo_x: Like “Restaurant” becomes “restaurant” in the test in this example: http://docs.djangoproject.com/en/dev/topics/db/models/#id7
<jMyles> igloo_x: Also, in that example, how can I ask if the object is NOT in the child class “restaurant”?
<jMyles> igloo_x: I’m looking at the third code block down from that link – “If you have a Place  that is also a Restaurant, you can get from the Place object to the Restaurant  object by using the lower-case version of the model name:”
<igloo_x> it’s magic, as far as I know. you can override it though. I think the argument is ‘related_name’ or something
<jMyles> igloo_x: OK, that’s what I thought.  :-)   And then, how can I ask if an object is NOT in that class?
<jMyles> igloo_x: ie, “if p.restaurant:” works fine, but how can I ask if it is not in that child class?
<igloo_x> i’m not sure about that, I’ve never messed with model inheritance before
<igloo_x> does “if not p.restaurant:” work though?
<jMyles> igloo_x: wow.  yes it does – mad overthinking on my part.
<igloo_x> good old python!
Good old Python indeed.  And therein I think lies the deeper truth: No matter what framework we use, it is imperative that developers adopt the philosophy of the language on which that framework is built, even if this means some extra time studying, sitting quietly, talking with friends, etc.
If I had allowed my mind to relax for a few minutes and really thought about the *context* in which this unexpected “magic” had arisen, surely my mind knew the way out of the situation.  That is the true developer discipline that is yet ahead for me.

Google did nothing wrong by collecting wifi data with the streetcar.

June 1st, 2010 at 12:41 pm

3033520.binCan somebody please explain what Google did wrong?

They drove around with a car, taking photos of the public surroundings of their car (that’s how they make StreetView).  While so doing, they picked up and recorded whatever wireless signals were coming in to their car.

Now people are whining that they are being spied upon.

Does anybody really think that preventing this kind of conduct has anything to do with making our communities secure against unwanted surveillance?  Is this line of defense the best we’ve got?

If you stand at your doorway, yelling at the top of your lungs about many intimate, private details of your life, is it fair to accuse a passerby of illegal (or unethical) surveillance because they happen to be recording their surroundings with an audio recorder?

Do you think that members of congress will rally to your defense, accusing those same pedestrians of spying on you?

There are plenty of very secure options for wireless communication.  If you aren’t using any of them, that’s your prerogative.  If you abstain from secure practices while at the same time communicating about sensitive issues which you bizarrely regard as private, that’s your problem.

On the bigger issue of Google being a scary monster of information collection… Sure, I see your point.  While on one hand, the information they collect is, in every practice I know of, voluntary (search phrases, email contents on Gmail, advertising clicks, cookies, the Google Toolbar, and many other methods), it’s not any less scary that they know more than anybody else about the modern polity.

I’m not usually a defender of google or any other giant corporation – I’ve expressed my fair share of google skepticism.  In this case, I think they’ve actually done wrong by repeatedly apologizing, but I guess that’s a PR move.

Nevertheless, their amazing (and thankless!) gift two weeks ago of releasing the VP8 codec to the public domain under an open source license was perhaps the single most significant act of bolstering independent radical journalism in the (still short) history of website-based video delivery.  Still not as profound as the movement that Miro represents, I’ll grant, but big (and a LOT more expensive).

To my mind, Google gave us as $124.6 million dollar gift, and I think we have a responsibility to accept it in full if we want to take advantage of it. That means in turn taking full responsibility for our network presence.  If your upload stream includes poignant, radical, inspirational content encoded in a free codec for the world to cherish, good.  If your upload stream (and wireless connection) includes unencrypted content that you irrationally regard as private, bad.


What ever happened to Paul Schene?

March 1st, 2010 at 9:39 am

Do you know that name? Paul Schene?

It’s not really a name worth remembering, as the person who is identified by that name is not worth the oxygen that he removes from the atmosphere during respiration.

Paul Schene is the criminal scumbag who beat the shit out of a 15-year old girl and dragged her around by her hair in Seattle (warning: shocking video). He also happens to be a police officer, suckling on the public teet to feed himself between abusive episodes. Oh, and he’s possibly also a murderer, as I discovered (and put the Huffington Post onto) a year ago today.

As far as I know, he hasn’t yet departed the mortal coil and departed for hell yet, so I’m wondering: does anybody know where he is now?

I just emailed Sgt. Sean Whitcomb, the media relations director for the Seattle PD:


Hello there – I’m a journalist from New York. I’m just wondering – what ever happened to Paul Schene? Is he still on administrative leave? If so, is it paid or unpaid? Has the case against him progressed at all?

I’ll let you know if he responds. Sgt. Whitcomb had this to say:


Hey Justin,

I work for the Seattle Police Department. Paul Schene formerly worked for the King County Sheriff’s Office. I believe he was fired, charged, acquitted by “hung jury” and awaiting retrial. Call either KCSO or check the Seattle Times for the latest updates.

Best regards,

Sean

…..so, I’ve emailed the only email address I can find for the KCSO (sheriff@kingcounty.gov) and asked the same question.

Another Update:

Sgt. Jim Laing of the King’s County Sheriff’s Office says:

Paul Schene was terminated for cause by the Sheriff on September 9, 2009 after an internal investigation. He was charged with assault and tried in January, 2010. This resulted in a mistrial. He is to be tried again on June 1, 2010.

Also:

I am getting quite a lot of traffic for the search phrase “Paul Schene.”  I have checked and in fact this page is the #1 search result for that phrase.  I surmise that Paul has now read this article.  So, Mr. Schene, what say you?  I want to offer you the opportunity to be seen as a human being and begin to clean up your tarnished name.  I’ll post whatever response you have – front, top, and center of this post – if you send it immediately.  If, on the other hand, you wait until the end of your trial in an effort to “decline to speak while legal action is pending,” an excuse I find detestable, you will lose this opportunity to control the content that is most strongly associated with your name in the world.  I suggest starting with a sincere apology.  Email me at justin@justinholmes.com.


Free Software and Drug Policy Reform – my presentation at the DPA conference in Albuquerque

December 6th, 2009 at 8:29 pm

I was honored to be invited to speak at a very small panel at the largest and most prestigious gathering of experts in the fields of drugs and drug policy – the drug policy alliance biennial conference. I spoke about the free software movement’s view of cognitive liberty, and why the drug policy reform movement is a natural ally for free and open source software.
YouTube Preview Image

….now before you jump on me about the “order of magnitude” comment with encryption – I fully realize that with increasing strength that decryption becomes several orders of magnitude more difficult, but as this was not a technology conference, I didn’t want to belabor the point. :-)