blob: 3fc053aeabd64b3142e9081086f3fc4166b7e640 (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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
 |