Dynamic URL shortening

Littlefield, Tyler tyler at tysdomain.com
Wed Jun 15 00:03:39 EDT 2011


Hello all:
I started working on a project with someone else quite recently, and he 
has a request. The project requires an URL shortener, and he would like 
it to be dynamic for both users and developers. Apparently some 
applications on the mac allow for the user to input some data on a URL 
shortener and use that specific service to shorten URLS. So I'm curious 
if anyone has had any experience with this in python/can recommend a 
library to look at.

Secondly, my requirement to make this dynamic for developers. The way I 
did this was to use a metaclass that the base URLShortener will inherit, 
which will add itself to a shortener registry. This works well enough, 
and all I really need to do is something like:
shortener = factory.getShortener("bitly")
url = shortener.shorten("http://google.com")
How viable is this solution? It seems like it's nice enough, are there 
other approaches to handling something like this?

-- 

Take care,
Ty
my website:
http://tds-solutions.net
my blog:
http://tds-solutions.net/blog
skype: st8amnd127
My programs don't have bugs; they're randomly added features!




More information about the Python-list mailing list