1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 """For resources fetched from location specified by URLs."""
17
18 from muntjac.service.file_type_resolver import FileTypeResolver
19 from muntjac.terminal.resource import IResource
20
21
23 """C{ExternalResource} implements source for resources fetched
24 from location specified by URLs. The resources are fetched directly by
25 the client terminal and are not fetched trough the terminal adapter.
26
27 @author: Vaadin Ltd.
28 @author: Richard Lincoln
29 @version: 1.1.2
30 """
31
32 - def __init__(self, sourceURL, mimeType=None):
33 """Creates a new download component for downloading directly from
34 given URL.
35
36 @param sourceURL:
37 the source URL.
38 @param mimeType:
39 the MIME Type
40 """
41
42 self._sourceURL = None
43
44 self._mimeType = None
45
46 if mimeType is None:
47 if sourceURL is None:
48 raise RuntimeError('Source must be non-null')
49 self._sourceURL = sourceURL
50 else:
51 ExternalResource.__init__(self, sourceURL)
52 self._mimeType = mimeType
53
54
56 """Gets the URL of the external resource.
57
58 @return: the URL of the external resource.
59 """
60 return self._sourceURL
61
62
64 """Gets the MIME type of the resource.
65
66 @see: L{muntjac.terminal.resource.IResource.getMIMEType}
67 """
68 if self._mimeType is None:
69 self._mimeType = FileTypeResolver.getMIMEType(self.getURL())
70 return self._mimeType
71
72
74 """Sets the MIME type of the resource."""
75 self._mimeType = mimeType
76