From 1210c461e575e14b4b8eb90f429757456cbea8e0 Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Sun, 12 Apr 2009 18:45:51 -0500 Subject: Added docs, and fixed a bug that writing the docs revealed. --- src/shorturls/templatetags/shorturl.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/shorturls/templatetags/shorturl.py b/src/shorturls/templatetags/shorturl.py index 5d4ec5e..2eef0ce 100644 --- a/src/shorturls/templatetags/shorturl.py +++ b/src/shorturls/templatetags/shorturl.py @@ -26,19 +26,19 @@ class ShortURL(template.Node): prefix = self.get_prefix(obj) except (AttributeError, KeyError): return '' - + + tinyid = base62.from_decimal(obj.pk) + + if hasattr(settings, 'SHORT_BASE_URL') and settings.SHORT_BASE_URL: + return urlparse.urljoin(settings.SHORT_BASE_URL, prefix+) + try: - url = urlresolvers.reverse('shorturls.views.redirect', kwargs = { + return urlresolvers.reverse('shorturls.views.redirect', kwargs = { 'prefix': prefix, - 'tiny': base62.from_decimal(obj.pk) + 'tiny': tinyid }) except urlresolvers.NoReverseMatch: return '' - - if hasattr(settings, 'SHORT_BASE_URL') and settings.SHORT_BASE_URL: - return urlparse.urljoin(settings.SHORT_BASE_URL, url) - else: - return url def get_prefix(self, model): if not hasattr(self.__class__, '_prefixmap'): -- cgit v1.2.3