Wednesday Wrap Up — October 2014 Edition

Being fairly new to this “regular blogging” habit that I’m trying to form, I’ve decided that the first Wednesday of every month will be known as “Wrap Up Wednesday” here on  What I plan to do is simply summarize everything that either influenced me, entertained me, or general buzz that interested me from the previous month. Some of it may be related directly to Salesforce but buyer beware — I’m a man of many interests so there may be some other things that sneak in from time to time. So without further delay, welcome to the first of hopefully many “Wednesday Wrap Ups!”

Personal Happenings:

  • Highlight of my year: I got to sing at Dreamforce! (Okay, i really will shut up about this…someday.)
  • I had a lightbulb moment
  • I reflected (perhaps out of place) on what I think makes a Salesforce MVP
  • Sarah Deutsch asked me to rewrite the lyrics to “All About That Bass” and she totally rocked it!
  • I smoked my first cigar and had my first Armagnac thanks to my new buddy Adam Daw. Armagnac — hell yes. Cigar — I’ve got much to learn…maybe @MichaelForce can help.

Dreamforce 2014:

  • The developer group over at Salesforce launched “Trailhead” and I’ve been enjoying watching the tweets come through as people complete the modules/challenges. I’ve not gotten very far myself, but intend to go front to back through all of the content. Some will be review but we can always use review. I’ve already referred a personal friend to it to get him up and going with Salesforce. I can’t wait to watch his progress & its a great way to started on the platform.
  • Lightning Components were opened up to developers and it promises to be slick as hell. I’ve only been able to spend a few hours with it so far, but I believe it will change much of what a developer on the platform does in the future. Our jobs won’t change immediately, there will always be enough apex work to go around, but things will indeed change. Jeff Douglas has a great intro to lightning so check it out.
  • Process Builder seems to be getting quite a bit of attention as well and really will shake things up in admin land. Brian Kwong (aka SalesforceWizard) has several good entries regarding process builder. I’ve not had the chance to do much besides give it a glance at this point but I believe its open beta so it would behoove you to get on this now.
  • Salesforce released Wave and next generation analytics platform. To be honest, I was wowed by the demo at the keynote — but that’s as far as I took it. I can’t focus on everything and I’m scattered as it is :)
  • POODLE just doodled all over SSL. On October 14th google engineers released information regarding a flaw in the SSL 3.0 protocol. Salesforce announced they’ll be shutting down that protocol and mass hysteria ensued. Its all very confusing and hard to even tell if one will be affected by it. There is a link on stackexchange that goes into excruciating detail of what the problem is and further down there is a link that will help you figure out which services may have a problem with this, but for the impatient…I think the magic you are looking for upon test completion is in the configuration section of the results. You’re looking for support of TLS 1.0 at least.

Other tech related stuff:

  • Apple CEO Tim Cook comes out as gay. This shouldn’t matter, but sadly we still live in a world where people think this an issue of some sort.
  • Apple Yosemite was released — and I like it :)
  • The Django project added four new core team members. Congrats folks!
  • An Indiegogo project was launched to help Django provide first class support for third party templating engines. I personally prefer the tempting framework that Django provides out of the box, but this can only help…

There are many more items of tech interest that I am sure I am leaving out but these are the ones I am remembering. This month, perhaps I’ll start bookmarking these things…I just hope I can keep this habit up! For now…



Wrapping non-ascii characters in Django

One of our long time clients recently hired a very talented design firm to give their site — and brand — a facelift. During said facelift a very strange font was selected that we had to serve up via embedded fonts. It just so happened however that this font for some reason had very large registered trademark symbols. So large in fact that our client mandated that we “find a way” to fix it.

After some consideration, I decided the best way to approach such an issue was to create a custom filter that we could use wherever we were expecting the database to hand us one of these symbols. (Since our database is using UTF-8, we’re able to literally store those symbols directly in the db — or at least that’s how I understand it, and is pretty evident when you perform a select on one of their products).

For the impatient, what I ended up with:

def wrap_symbol(value, classname):
    Looks for registered trademark symbols and wraps them in 
    a css class to allow for styling.

    {{ string|wrap_symbol:'classname' }}

    TODO: allow specification of symbol(s) to replace
classname = smart_str(classname)
repl_text = "<span class='" + classname + "'>\xc2\xae</span>"

    string = smart_str(value).replace('\xc2\xae', smart_str(repl_text))
except ValueError, exp:
    return value
return mark_safe(string)

But my first attempt had the replacement taking place as such:

string = value.replace("\xc2\xae\", "<span class='" + classname + "'>\xc2\xae</span>")

I was repeatedly met with the following error: ‘ascii’ codec can’t encode character 0xca2 in position 0: ordinal not in range(128). While I didn’t expect it to work out of the gate — as things rarely tend to do for me — I was in no way expecting the multi-hour battle that would ensue, (largely due to my lack of understanding of character encodings and some unexpected output from print statements, but I digress) — off to the shell for some experimentation:

>>> from products.models import Product
>>> p = Product.objects.get(pk=25)
CompanyName\xae ProductName\xae
>>> print
CompanyName® ProductName #(I'm paraphrasing here)
>>> print unicode(
CompanyName® ProductName
>>> unicode(
CompanyName\xae ProductName\xae

Had I only noticed the pattern that emerged during the above commands, I mightn’t be writing this post…nevertheless, continuing, I knew that the DB should be giving me back the UTF-8 representation so I hit the great google for guidance. Through various articles and even a trip to #python and #django, I ended up trying something like:

CompanyName\xc2\xae ProductName\xc2\xae

Aha! Something different — if only slightly — but different enough to send me down another black hole. After many a google search, I came across this which ultimate led me to my final working destination.

Sadly it wasn’t until after I had things working that I realized what was holding me up in my testing. Anytime I called “print” from the shell or from my code, etc — print was converting the output for me. (It was doing it right in front of my eyes, but apparently I refused to believe it.) Investigating using python’s “type()” method, entering type( definitely returned ‘unicode’ so for the life of me I couldn’t figure out why my debug statements kept having the actual symbol print out, which was further muddying my already cloudy understanding of the issue.

After one final hiccup involving the insertion actual replacement text: \xc2\xae back into the string, I had a working filter that I can now use across my entire site. I’m not entirely sure that I still grasp what exactly what was/is going on, but the of django’s utilities make it so much easier to deal with this sort of thing. Man these guys thought of _everything_.