This Just-in! Justin Myles Holmes

by Justin Myles Holmes

Posts categorized “Technology”


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.

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.


Warning: simplexml_load_file(http://services.digg.com/stories/?link=http%3A%2F%2Fjustinholmes.com%2F2009%2F12%2Ffree-software-and-drug-policy-reform-my-presentation-at-the-dpa-conference-in-albuquerque%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%2F2009%2F12%2Ffree-software-and-drug-policy-reform-my-presentation-at-the-dpa-conference-in-albuquerque%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%2F2009%2F12%2Ffree-software-and-drug-policy-reform-my-presentation-at-the-dpa-conference-in-albuquerque%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%2F2009%2F12%2Ffree-software-and-drug-policy-reform-my-presentation-at-the-dpa-conference-in-albuquerque%2F&appkey=http%3A%2F%2Fjustinholmes.com&type=xml" in /home/justinho/public_html/wp-content/themes/justinholmes/flexpost.php on line 35

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. :-)


Warning: simplexml_load_file(http://services.digg.com/stories/?link=http%3A%2F%2Fjustinholmes.com%2F2009%2F10%2Fresistors-of-socialized-medicine-must-offer-a-more-systemic-vision-of-health-care%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%2F2009%2F10%2Fresistors-of-socialized-medicine-must-offer-a-more-systemic-vision-of-health-care%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%2F2009%2F10%2Fresistors-of-socialized-medicine-must-offer-a-more-systemic-vision-of-health-care%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%2F2009%2F10%2Fresistors-of-socialized-medicine-must-offer-a-more-systemic-vision-of-health-care%2F&appkey=http%3A%2F%2Fjustinholmes.com&type=xml" in /home/justinho/public_html/wp-content/themes/justinholmes/flexpost.php on line 35

Resisters of socialized medicine must offer a more systemic vision of health care.

October 23rd, 2009 at 9:33 am

As with pretty much every area of political discourse in the United States today, the congressional wrangling over health care lacks a thoughtful, compassionate, informed republican perspective.

Of course the (captial-R) Republican Party has been a miserable failure in representing (small-r) republican views in my lifetime, so I’m not sure why in this instance I expect anything more.

The problem is that in this instance, the statist / socialist perspective is fundamentally correct about one thing: The health care system of the United States is poorly designed for efficiency and efficacy as a system.

Imagine, if the current system were invented as a full system, the kind of conversation leading to its invention: “Let’s base health coverage around employment status – most of the people who are employed can have a product we’ll call “insurance” but that will really be a buffet-style hodgepodge of health services. We’ll have a whole slew of different plans and practices so as to avoid large-scale negotiation for the benefit of the consumer. People who are self-employed or not-employed will be kinda screwed, as will those who happen to be sick the day before they get a job – pre-existing conditions are a liability, you know. People who are young and destitute or people who are over a particular arbitrary age will be covered by a mix of their home state government and the federal government. All the while, no solid block of informed consumers will exist to challenge the status quo as a market force.”

Now I realize that’s an oversimplification, but my point is that, while pretty much everybody sees the need for a massive change to the health care system, only the statist / socialist perspective has risen up with a really great sounding alternative:

“Every single person will be required to pay into a collective hold, for which on their behalf a single entity will negotiate the best prices and practices. Each person then will be entitled to coverage with a fraction of a percent of the system’s resources leaving as overhead or profit.”

It’s not hard to understand how a person can find this alternative compelling!

Making it even more difficult to resist, proponents are able to point to many nation-states around the world where such systems are deployed effectively and to the delight of the citizenry.

Now, on the other hand, look at the narrative of reform offered by the anarchist / republican perspective. I don’t know of one. I can’t think of one! Instead, we merely point out the many (and scary) inevitable pitfalls of asking the most powerful military hegemon in history to take care of our health. We sound terribly academic and disconnected, and we offer no systemic perspective on what our ideal system will look like.

This is the problem.

Thus, henceforth, I’m suggesting that we stop or at least curtail all criticism of the current “reform” proposals. We take Obama (and the curious word “Obamacare”) out of our lexicon and out of our cross-hairs. Instead we relentlessly espouse our vision for taking care of people – all people – without the heavy hand of government.

I don’t know all the details, but just to get us started, it goes something like this:

We start by ending all criminal liability for the act of putting anything into one’s own body. We restore and strengthen the notion that, across the system, each person is the sole owner and operator of their own biological organism.

We restore and re-examine the role of plant-based medicines, making coca, poppy, hemp, and all other plants legal to cultivate.

We repeal those laws which create the artificial concept of “intellectual property,” at least as far as psychoactive compounds are concerned. We thus end government protection of pharmaceutical companies who inflate their prices by thousands of percent. Medicines of all kinds become affordable again, and lo and behold! More, rather than fewer, enterprising young scientists become interested in open source medicine.

We create a rich, comfortable, and easy-to-use wiki-like environment, in which people can list the symptoms of any malady from which they may be suffering. They can also list the remedies which have helped them in the past, and together, as a community, we can create a massive database of trends for all sorts of diseases.

In this online environment, people in similar biological conditions can talk to one another in a live environment and have occasional support meetings and form consumer support-and-wellness groups.

Practitioners of medicine, both conventional and alternative, can advertise their services and be hired as advisors by these support groups, being paid directly instead of through a convoluted coverage system. If, for example, they want to make $50 / hour, they can charge a 10-person group $10 each for a two-hour session, and answer all of their questions.

The concept of “insurance” can be re-introduced and distinguished from buffet-style comprehensive coverage. Most people will likely opt-out of insurance, realizing that the act of purchasing insurance is actually a bet that they will become sick or die sooner rather than later. On the other hand, some will purchase policies to cover unlikely catastrophic events. Such insurance will be very cheap.

People can once again choose for themselves which tests and procedures are important, and the incentive structure will be one of conservation, as they’ll have to pay for each one.

As overhead and systemic costs are reduced, people who currently find themselves spending outrageous amounts on “coverage” for themselves, their families, and their employees can instead invest in medical centers or charities in their communities which can care for people who truly need complicated and expensive procedures but can’t pay for them.

Support groups can also use their presence to help doctors help the poor. In the example above, if each participant pays $11 for the session, the doctor will have an extra $10. Assuming the doctor is willing to work for half price for charity, she needs to administer only five such sessions a week in order to administer a free one for people who cannot afford the $10 fee. Surgeons can work the same way, albeit on a larger scale, just as they did before government regulation got us into the mess we are in today.

Some doctors and other medical professionals will make long-lasting relationships and be able to charge a bit more money as they get older and more trusted. Some of them will make very good money practicing their art, and that’s OK. In fact, that’s great. Young people will again have a reason to follow their passion for caring about people instead of studying pharmaceutical patent law or insurance adjustment expediting.

Of course none of us has all the answers, but I think that most people have never stopped to think about what kind of alternative the republican / anarchist perspective has to offer in the health care debate. It’s time to change that.

Also, and perhaps most importantly, the open-source movement and the progress of technology make all of these ideas (and lots of even more innovate ideas!) not only possible, but inevitable. So it’s time for us to become optimistic and take some pride in our ability to help each other and keep each other well.