September 8, 2010

Going to Hostingcon 2006

The Mirage CasinoAs a last minute opportunity, I’m going to attend HostingCon 2006. My boss can’t make it, so I’ll attend in his place.

This is a nice opportunity, since it will be the first time I’ve ever attended a conference with the explicit instruction to “make contacts and develop relationships with __________ vendors.” I’ve never even attended a con where people were particularly interested in me or my business, but this time I’ll be the representative of a large hosting provider.

I don’t gamble or drink, so I always feel a bit out of place in Las Vegas, but the place still fascinates me with its huge money, superficiality, growth, excess, and runaway success. I’ll have a good time.
[tags]Las Vegas, Hostingcon, conventions[/tags]

Speedy Django Development

GuitarAs I’ve mentioned before, I am building my own web store using Django. The coding is going extremely quickly, thanks to the excellence of the framework.

I find myself marvelling at how quickly and simply various elements come together, especially when I contrast this to my previous experience doing the same thing with Java for an employer.

For example, the Login/User framework. With Django, I simply include the auth middleware, and create a couple templates to “skin” the login, profile, password change, and password reset pages. In return, I get a full-featured, working login system with sessions, cookies, and all that tedious plumbing done for me. Total time from decision to use the built-in framework to implementation? Two hours, including learning the system. Unbelievable.

Contrast that with my use of Acegi/Spring to handle authentication in a Java app. I was shockingly fast implementing this, taking just two full working days. The documentation directly states that you should plan on at the very least one full week. The system was huge, slow, and baroque. Modifying the system was clumsy and frequently required I relearn things from the reams of documentation. Yes, overall it offered more functionality. No, there was no stripped-path to just get the most needed set of features for a website. The craziest thing is that the config files for Acegi
alone were larger than all the code and templates I wrote for django login
.

Another example is my need to generate thumbnails for some graphics. I want to generate them “on the fly”, when needed. Total lines of code to do this in Python with PIL, integrated with Django? 7. Total time? 15 minutes, including all the logic needed to make sure that I only create the thumbnail once.

Contrast this with the nightmare that is the Java image API. I seriously spent days making a caching thumbnailing system in Java for an Auction site I worked on. Even after that, it was much slower than my Python solution.

Now that I am actually developing a serious app for Django, I find myself feeling the love more and more. Thanks Django team!
[tags]django,python,spring,acegi,pil[/tags]

The best python url_join routine ever

thumbs upI don’t know how many times I’ve had to write a function to safely join url path components. It seems so simple, “Just join the strings together with forward slashes.”

But, then I think, “Oh, and don’t strip the leading forward slash, if any”. And “oh, also don’t strip the trailing one”. Also, “make sure not to double up any slashes.”

It is an annoying routine to write, and to be honest, I’ve never really liked any of my implementations. They always failed on some edge case. But tonight, I conquered.

So, without further delay, here is my perfect url_join routine. It hasn’t failed any reasonable edge case I’ve thrown at it yet! The backslash replacement parts are to make it windows compatible, but of course I haven’t tested those.


def url_join(*args):
    """Join any arbitrary strings into a forward-slash delimited list.
    Do not strip leading / from first element, nor trailing / from last element."""
    if len(args) == 0:
        return ""

    if len(args) == 1:
        return str(args[0])

    else:
        args = [str(arg).replace("\\", "/") for arg in args]

        work = [args[0]]
        for arg in args[1:]:
            if arg.startswith("/"):
                work.append(arg[1:])
            else:
                work.append(arg)

        joined = reduce(os.path.join, work)

    return joined.replace("\\", "/")

[tags]python[/tags]

Sqlite3 made Safari Crash

CrashShort story: upgrading SQLITE3 makes Safari crash in OSX.

Using Sqlite on several systems recently, I decided to upgrade the installed Sqlite on my Macbook Pro. Otherwise I kept running into version incompatibility problems between the Linux systems and my Mac.

Compiling was easy enough, but by habit before I installed the new libraries, I made a backup of the current libraries. Good move.

Since upgrading, I noticed that several apps started crashing on start. Safari & Ecto were the worst offenders. This morning, I finally had enough and began digging into the root cause.

Aha! Sqlite3 library errors. Seems the Safari engine needs Sqlite the way it was installed. A quick rollback and Safari and my old friend Ecto are once again happy. Annoying for my cross compatibility needs, but I’ll just have to figure out how to make the old and new ones run side-by-side.

p.s. I’m back from vacation, and regular posting will now resume.

[tags]crash,safari,sqlite[/tags]