aboutsummaryrefslogtreecommitdiffstats
path: root/brevisurl/backends/base.py
diff options
context:
space:
mode:
authorVladimir Gorej2012-05-27 20:14:17 +0200
committerVladimir Gorej2012-05-27 20:14:17 +0200
commit4bd7b72aa0ca3a09ab99e1a3b41753df81de6af9 (patch)
tree6328ed9894666eefc1f0d6b6c7b28a87b1fb4d31 /brevisurl/backends/base.py
downloaddjango-brevisurl-4bd7b72aa0ca3a09ab99e1a3b41753df81de6af9.tar.bz2
Initial commit
Diffstat (limited to 'brevisurl/backends/base.py')
-rw-r--r--brevisurl/backends/base.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/brevisurl/backends/base.py b/brevisurl/backends/base.py
new file mode 100644
index 0000000..3fc053a
--- /dev/null
+++ b/brevisurl/backends/base.py
@@ -0,0 +1,41 @@
+from abc import ABCMeta
+
+
+class BaseBrevisUrlBackend(object):
+ """Base class for brevisurl backend implementations. Subclasses must at least overwrite shorten_url()."""
+
+ __metaclass__ = ABCMeta
+
+
+ def __init__(self, fail_silently=False, **kwargs):
+ self.fail_silently = fail_silently
+ self.class_path = '{0}.{1}'.format(self.__module__, self.__class__.__name__)
+
+ def open(self):
+ """Open a network connection.
+
+ This method can be overwritten by backend implementations to
+ open a network connection.
+
+ It's up to the backend implementation to track the status of
+ a network connection if it's needed by the backend.
+
+ The default implementation does nothing.
+
+ """
+ pass
+
+ def close(self):
+ """Close a network connection."""
+ pass
+
+ def shorten_url(self, original_url):
+ """Shortens url into more compact form.
+
+ :param original_url: url that will be shortened
+ :type original_url: string
+ :returns: shortened url from original url
+ :rtype: brevisurl.models.ShortUrl
+
+ """
+ raise NotImplementedError \ No newline at end of file