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