Show More
@@ -112,31 +112,21 b' class RepoFeedView(RepoAppView):' | |||
|
112 | 112 | @LoginRequired(auth_token_access=[UserApiKeys.ROLE_FEED]) |
|
113 | 113 | @HasRepoPermissionAnyDecorator( |
|
114 | 114 | 'repository.read', 'repository.write', 'repository.admin') |
|
115 | @view_config( | |
|
116 |
|
|
|
117 | renderer=None) | |
|
118 | @view_config( | |
|
119 | route_name='atom_feed_home_old', request_method='GET', | |
|
120 | renderer=None) | |
|
115 | @view_config(route_name='atom_feed_home', request_method='GET', renderer=None) | |
|
116 | @view_config(route_name='atom_feed_home_old', request_method='GET', renderer=None) | |
|
121 | 117 | def atom(self): |
|
122 | 118 | """ |
|
123 | 119 | Produce an atom-1.0 feed via feedgenerator module |
|
124 | 120 | """ |
|
125 | 121 | self.load_default_context() |
|
126 | 122 | |
|
127 |
cache_namespace_uid = 'cache_repo_ |
|
|
128 | self.db_repo.repo_id, CacheKey.CACHE_TYPE_FEED) | |
|
129 | invalidation_namespace = CacheKey.REPO_INVALIDATION_NAMESPACE.format( | |
|
130 | repo_id=self.db_repo.repo_id) | |
|
131 | ||
|
132 | region = rc_cache.get_or_create_region('cache_repo_longterm', | |
|
133 | cache_namespace_uid) | |
|
134 | ||
|
123 | cache_namespace_uid = 'cache_repo_feed.{}'.format(self.db_repo.repo_id) | |
|
135 | 124 | condition = not self.path_filter.is_enabled |
|
125 | region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid) | |
|
136 | 126 | |
|
137 | 127 | @region.conditional_cache_on_arguments(namespace=cache_namespace_uid, |
|
138 | 128 | condition=condition) |
|
139 | def generate_atom_feed(repo_id, _repo_name, _feed_type): | |
|
129 | def generate_atom_feed(repo_id, _repo_name, commit_id, _feed_type): | |
|
140 | 130 | feed = Atom1Feed( |
|
141 | 131 | title=self.title % _repo_name, |
|
142 | 132 | link=h.route_url('repo_summary', repo_name=_repo_name), |
@@ -159,18 +149,9 b' class RepoFeedView(RepoAppView):' | |||
|
159 | 149 | |
|
160 | 150 | return feed.mime_type, feed.writeString('utf-8') |
|
161 | 151 | |
|
162 | inv_context_manager = rc_cache.InvalidationContext( | |
|
163 | uid=cache_namespace_uid, invalidation_namespace=invalidation_namespace) | |
|
164 | with inv_context_manager as invalidation_context: | |
|
165 | args = (self.db_repo.repo_id, self.db_repo.repo_name, 'atom',) | |
|
166 | # re-compute and store cache if we get invalidate signal | |
|
167 | if invalidation_context.should_invalidate(): | |
|
168 | mime_type, feed = generate_atom_feed.refresh(*args) | |
|
169 | else: | |
|
170 | mime_type, feed = generate_atom_feed(*args) | |
|
171 | ||
|
172 | log.debug('Repo ATOM feed computed in %.4fs', | |
|
173 | inv_context_manager.compute_time) | |
|
152 | commit_id = self.db_repo.changeset_cache.get('raw_id') | |
|
153 | mime_type, feed = generate_atom_feed( | |
|
154 | self.db_repo.repo_id, self.db_repo.repo_name, commit_id, 'atom') | |
|
174 | 155 | |
|
175 | 156 | response = Response(feed) |
|
176 | 157 | response.content_type = mime_type |
@@ -179,30 +160,21 b' class RepoFeedView(RepoAppView):' | |||
|
179 | 160 | @LoginRequired(auth_token_access=[UserApiKeys.ROLE_FEED]) |
|
180 | 161 | @HasRepoPermissionAnyDecorator( |
|
181 | 162 | 'repository.read', 'repository.write', 'repository.admin') |
|
182 | @view_config( | |
|
183 |
|
|
|
184 | renderer=None) | |
|
185 | @view_config( | |
|
186 | route_name='rss_feed_home_old', request_method='GET', | |
|
187 | renderer=None) | |
|
163 | @view_config(route_name='rss_feed_home', request_method='GET', renderer=None) | |
|
164 | @view_config(route_name='rss_feed_home_old', request_method='GET', renderer=None) | |
|
188 | 165 | def rss(self): |
|
189 | 166 | """ |
|
190 | 167 | Produce an rss2 feed via feedgenerator module |
|
191 | 168 | """ |
|
192 | 169 | self.load_default_context() |
|
193 | 170 | |
|
194 |
cache_namespace_uid = 'cache_repo_ |
|
|
195 | self.db_repo.repo_id, CacheKey.CACHE_TYPE_FEED) | |
|
196 | invalidation_namespace = CacheKey.REPO_INVALIDATION_NAMESPACE.format( | |
|
197 | repo_id=self.db_repo.repo_id) | |
|
198 | region = rc_cache.get_or_create_region('cache_repo_longterm', | |
|
199 | cache_namespace_uid) | |
|
200 | ||
|
171 | cache_namespace_uid = 'cache_repo_feed.{}'.format(self.db_repo.repo_id) | |
|
201 | 172 | condition = not self.path_filter.is_enabled |
|
173 | region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid) | |
|
202 | 174 | |
|
203 | 175 | @region.conditional_cache_on_arguments(namespace=cache_namespace_uid, |
|
204 | 176 | condition=condition) |
|
205 | def generate_rss_feed(repo_id, _repo_name, _feed_type): | |
|
177 | def generate_rss_feed(repo_id, _repo_name, commit_id, _feed_type): | |
|
206 | 178 | feed = Rss201rev2Feed( |
|
207 | 179 | title=self.title % _repo_name, |
|
208 | 180 | link=h.route_url('repo_summary', repo_name=_repo_name), |
@@ -222,20 +194,11 b' class RepoFeedView(RepoAppView):' | |||
|
222 | 194 | 'repo_commit', repo_name=_repo_name, |
|
223 | 195 | commit_id=commit.raw_id), |
|
224 | 196 | pubdate=date,) |
|
225 | ||
|
226 | 197 | return feed.mime_type, feed.writeString('utf-8') |
|
227 | 198 | |
|
228 | inv_context_manager = rc_cache.InvalidationContext( | |
|
229 | uid=cache_namespace_uid, invalidation_namespace=invalidation_namespace) | |
|
230 | with inv_context_manager as invalidation_context: | |
|
231 | args = (self.db_repo.repo_id, self.db_repo.repo_name, 'rss',) | |
|
232 | # re-compute and store cache if we get invalidate signal | |
|
233 | if invalidation_context.should_invalidate(): | |
|
234 | mime_type, feed = generate_rss_feed.refresh(*args) | |
|
235 | else: | |
|
236 | mime_type, feed = generate_rss_feed(*args) | |
|
237 | log.debug( | |
|
238 | 'Repo RSS feed computed in %.4fs', inv_context_manager.compute_time) | |
|
199 | commit_id = self.db_repo.changeset_cache.get('raw_id') | |
|
200 | mime_type, feed = generate_rss_feed( | |
|
201 | self.db_repo.repo_id, self.db_repo.repo_name, commit_id, 'rss') | |
|
239 | 202 | |
|
240 | 203 | response = Response(feed) |
|
241 | 204 | response.content_type = mime_type |
General Comments 0
You need to be logged in to leave comments.
Login now