This Just-in! Justin Myles Holmes

by Justin Myles Holmes


Warning: simplexml_load_file(http://services.digg.com/stories/?link=http%3A%2F%2Fjustinholmes.com%2F2010%2F07%2Fa-rare-example-of-magic-and-gnosticism-in-django%2F&appkey=http%3A%2F%2Fjustinholmes.com&type=xml) [function.simplexml-load-file]: failed to open stream: HTTP request failed! HTTP/1.0 503 Service Unavailable in /home/justinho/public_html/wp-content/themes/justinholmes/flexpost.php on line 35

Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "http://services.digg.com/stories/?link=http%3A%2F%2Fjustinholmes.com%2F2010%2F07%2Fa-rare-example-of-magic-and-gnosticism-in-django%2F&appkey=http%3A%2F%2Fjustinholmes.com&type=xml" in /home/justinho/public_html/wp-content/themes/justinholmes/flexpost.php on line 35

Warning: simplexml_load_file(http://services.digg.com/stories/?link=http%3A%2F%2Fjustinholmes.com%2F2010%2F07%2Fa-rare-example-of-magic-and-gnosticism-in-django%2F&appkey=http%3A%2F%2Fjustinholmes.com&type=xml) [function.simplexml-load-file]: failed to open stream: HTTP request failed! HTTP/1.0 503 Service Unavailable in /home/justinho/public_html/wp-content/themes/justinholmes/flexpost.php on line 35

Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "http://services.digg.com/stories/?link=http%3A%2F%2Fjustinholmes.com%2F2010%2F07%2Fa-rare-example-of-magic-and-gnosticism-in-django%2F&appkey=http%3A%2F%2Fjustinholmes.com&type=xml" in /home/justinho/public_html/wp-content/themes/justinholmes/flexpost.php on line 35

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.
  • StumbleUpon
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Technorati
  • Google Bookmarks
  • Reddit
  • email

Warning: simplexml_load_file(http://services.digg.com/stories/?link=http%3A%2F%2Fjustinholmes.com%2F2010%2F06%2Fgoogle-did-nothing-wrong-by-collective-wifi-data-with-the-streetcar%2F&appkey=http%3A%2F%2Fjustinholmes.com&type=xml) [function.simplexml-load-file]: failed to open stream: HTTP request failed! HTTP/1.0 503 Service Unavailable in /home/justinho/public_html/wp-content/themes/justinholmes/flexpost.php on line 35

Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "http://services.digg.com/stories/?link=http%3A%2F%2Fjustinholmes.com%2F2010%2F06%2Fgoogle-did-nothing-wrong-by-collective-wifi-data-with-the-streetcar%2F&appkey=http%3A%2F%2Fjustinholmes.com&type=xml" in /home/justinho/public_html/wp-content/themes/justinholmes/flexpost.php on line 35

Warning: simplexml_load_file(http://services.digg.com/stories/?link=http%3A%2F%2Fjustinholmes.com%2F2010%2F06%2Fgoogle-did-nothing-wrong-by-collective-wifi-data-with-the-streetcar%2F&appkey=http%3A%2F%2Fjustinholmes.com&type=xml) [function.simplexml-load-file]: failed to open stream: HTTP request failed! HTTP/1.0 503 Service Unavailable in /home/justinho/public_html/wp-content/themes/justinholmes/flexpost.php on line 35

Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "http://services.digg.com/stories/?link=http%3A%2F%2Fjustinholmes.com%2F2010%2F06%2Fgoogle-did-nothing-wrong-by-collective-wifi-data-with-the-streetcar%2F&appkey=http%3A%2F%2Fjustinholmes.com&type=xml" in /home/justinho/public_html/wp-content/themes/justinholmes/flexpost.php on line 35

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.

  • StumbleUpon
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Technorati
  • Google Bookmarks
  • Reddit
  • email

Warning: simplexml_load_file(http://services.digg.com/stories/?link=http%3A%2F%2Fjustinholmes.com%2F2010%2F05%2Fholy-fuck-animal-cruelty%2F&appkey=http%3A%2F%2Fjustinholmes.com&type=xml) [function.simplexml-load-file]: failed to open stream: HTTP request failed! HTTP/1.0 503 Service Unavailable in /home/justinho/public_html/wp-content/themes/justinholmes/flexpost.php on line 35

Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "http://services.digg.com/stories/?link=http%3A%2F%2Fjustinholmes.com%2F2010%2F05%2Fholy-fuck-animal-cruelty%2F&appkey=http%3A%2F%2Fjustinholmes.com&type=xml" in /home/justinho/public_html/wp-content/themes/justinholmes/flexpost.php on line 35

Warning: simplexml_load_file(http://services.digg.com/stories/?link=http%3A%2F%2Fjustinholmes.com%2F2010%2F05%2Fholy-fuck-animal-cruelty%2F&appkey=http%3A%2F%2Fjustinholmes.com&type=xml) [function.simplexml-load-file]: failed to open stream: HTTP request failed! HTTP/1.0 503 Service Unavailable in /home/justinho/public_html/wp-content/themes/justinholmes/flexpost.php on line 35

Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "http://services.digg.com/stories/?link=http%3A%2F%2Fjustinholmes.com%2F2010%2F05%2Fholy-fuck-animal-cruelty%2F&appkey=http%3A%2F%2Fjustinholmes.com&type=xml" in /home/justinho/public_html/wp-content/themes/justinholmes/flexpost.php on line 35

Holy. Fuck. Animal Cruelty.

May 26th, 2010 at 2:15 pm

I only watched the first 17 seconds of this video. I was unable to watch more.

YouTube Preview Image

I have emailed Mercy for Animals, the publisher of the video, asking for the names of people involved.

UPDATE:One of those featured in the video is Billy Joe Gregg Jr., who has been charged with 12 counts of animal cruelty. Each carries a measly maximum sentence of 90 days in jail. I can’t find a phone number for this scumbag, but if somebody does, please post it so we can be sure to let him know how we feel.

  • StumbleUpon
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Technorati
  • Google Bookmarks
  • Reddit
  • email

Warning: simplexml_load_file(http://services.digg.com/stories/?link=http%3A%2F%2Fjustinholmes.com%2F2010%2F05%2Ffaulty-thinking-syndrome%2F&appkey=http%3A%2F%2Fjustinholmes.com&type=xml) [function.simplexml-load-file]: failed to open stream: HTTP request failed! HTTP/1.0 503 Service Unavailable in /home/justinho/public_html/wp-content/themes/justinholmes/flexpost.php on line 35

Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "http://services.digg.com/stories/?link=http%3A%2F%2Fjustinholmes.com%2F2010%2F05%2Ffaulty-thinking-syndrome%2F&appkey=http%3A%2F%2Fjustinholmes.com&type=xml" in /home/justinho/public_html/wp-content/themes/justinholmes/flexpost.php on line 35

Warning: simplexml_load_file(http://services.digg.com/stories/?link=http%3A%2F%2Fjustinholmes.com%2F2010%2F05%2Ffaulty-thinking-syndrome%2F&appkey=http%3A%2F%2Fjustinholmes.com&type=xml) [function.simplexml-load-file]: failed to open stream: HTTP request failed! HTTP/1.0 503 Service Unavailable in /home/justinho/public_html/wp-content/themes/justinholmes/flexpost.php on line 35

Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "http://services.digg.com/stories/?link=http%3A%2F%2Fjustinholmes.com%2F2010%2F05%2Ffaulty-thinking-syndrome%2F&appkey=http%3A%2F%2Fjustinholmes.com&type=xml" in /home/justinho/public_html/wp-content/themes/justinholmes/flexpost.php on line 35

Faulty Thinking Syndrome

May 14th, 2010 at 4:21 pm

Very powerful.

YouTube Preview Image
  • StumbleUpon
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Technorati
  • Google Bookmarks
  • Reddit
  • email