equal
deleted
inserted
replaced
76 code=http.FORBIDDEN, |
76 code=http.FORBIDDEN, |
77 stream='Access forbidden') |
77 stream='Access forbidden') |
78 |
78 |
79 |
79 |
80 class NoListingFile(static.File): |
80 class NoListingFile(static.File): |
|
81 |
|
82 def set_expires(self, request): |
|
83 if not self.config.debugmode: |
|
84 # XXX: Don't provide additional resource information to error responses |
|
85 # |
|
86 # the HTTP RFC recommands not going further than 1 year ahead |
|
87 expires = date.today() + timedelta(days=6*30) |
|
88 request.setHeader('Expires', generateDateTime(mktime(expires.timetuple()))) |
|
89 |
81 def directoryListing(self): |
90 def directoryListing(self): |
82 return ForbiddenDirectoryLister() |
91 return ForbiddenDirectoryLister() |
83 |
92 |
84 |
93 |
85 class DataLookupDirectory(NoListingFile): |
94 class DataLookupDirectory(NoListingFile): |
105 if uri.startswith(self.data_modconcat_basepath): |
114 if uri.startswith(self.data_modconcat_basepath): |
106 resource_relpath = uri[len(self.data_modconcat_basepath):] |
115 resource_relpath = uri[len(self.data_modconcat_basepath):] |
107 if resource_relpath: |
116 if resource_relpath: |
108 paths = resource_relpath.split(',') |
117 paths = resource_relpath.split(',') |
109 try: |
118 try: |
|
119 self.set_expires(request) |
110 return ConcatFiles(self.config, paths) |
120 return ConcatFiles(self.config, paths) |
111 except ConcatFileNotFoundError: |
121 except ConcatFileNotFoundError: |
112 return self.childNotFound |
122 return self.childNotFound |
113 return self.directoryListing() |
123 return self.directoryListing() |
114 childpath = join(self.here, path) |
124 childpath = join(self.here, path) |
122 # cache resource for this segment path to avoid recomputing |
132 # cache resource for this segment path to avoid recomputing |
123 # directory lookup |
133 # directory lookup |
124 self.putChild(path, resource) |
134 self.putChild(path, resource) |
125 return resource |
135 return resource |
126 else: |
136 else: |
|
137 self.set_expires(request) |
127 return NoListingFile(filepath) |
138 return NoListingFile(filepath) |
128 |
139 |
129 |
140 |
130 class FCKEditorResource(NoListingFile): |
141 class FCKEditorResource(NoListingFile): |
131 def __init__(self, config, path): |
142 def __init__(self, config, path): |
154 etc. |
165 etc. |
155 |
166 |
156 """ |
167 """ |
157 def _defineChildResources(self): |
168 def _defineChildResources(self): |
158 pass |
169 pass |
159 |
|
160 def render(self, request): |
|
161 # XXX: Don't provide additional resource information to error responses |
|
162 # |
|
163 # the HTTP RFC recommands not going further than 1 year ahead |
|
164 expires = date.today() + timedelta(days=6*30) |
|
165 request.setHeader('Expires', generateDateTime(mktime(expires.timetuple()))) |
|
166 return DataLookupDirectory.render(self, request) |
|
167 |
170 |
168 |
171 |
169 class ConcatFileNotFoundError(CubicWebException): |
172 class ConcatFileNotFoundError(CubicWebException): |
170 pass |
173 pass |
171 |
174 |