##// END OF EJS Templates
added super simple cache_key paster function for showing and cleaning cache keys
marcink -
r3616:e9ac7544 beta
parent child Browse files
Show More
@@ -0,0 +1,85 b''
1 # -*- coding: utf-8 -*-
2 """
3 rhodecode.lib.paster_commands.cache_keys
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5
6 cleanup-keys paster command for RhodeCode
7
8
9 :created_on: mar 27, 2013
10 :author: marcink
11 :copyright: (C) 2010-2013 Marcin Kuzminski <marcin@python-works.com>
12 :license: GPLv3, see COPYING for more details.
13 """
14 # This program is free software: you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation, either version 3 of the License, or
17 # (at your option) any later version.
18 #
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License
25 # along with this program. If not, see <http://www.gnu.org/licenses/>.
26 from __future__ import with_statement
27
28 import os
29 import sys
30 import logging
31
32 from os.path import dirname as dn, join as jn
33 from rhodecode.model.meta import Session
34 #to get the rhodecode import
35 rc_path = dn(dn(dn(os.path.realpath(__file__))))
36 sys.path.append(rc_path)
37 from rhodecode.lib.utils import BasePasterCommand
38
39 from rhodecode.model.db import CacheInvalidation
40
41
42 log = logging.getLogger(__name__)
43
44
45 class Command(BasePasterCommand):
46
47 max_args = 1
48 min_args = 1
49
50 usage = "CONFIG_FILE"
51 group_name = "RhodeCode"
52 takes_config_file = -1
53 parser = BasePasterCommand.standard_parser(verbose=True)
54 summary = "Cache keys utils"
55
56 def command(self):
57 #get SqlAlchemy session
58 self._init_session()
59 _caches = CacheInvalidation.query().order_by(CacheInvalidation.cache_key).all()
60 if self.options.show:
61 for c_obj in _caches:
62 print 'key:%s active:%s' % (c_obj.cache_key, c_obj.cache_active)
63 elif self.options.cleanup:
64 for c_obj in _caches:
65 Session().delete(c_obj)
66 print 'removing key:%s' % (c_obj.cache_key)
67 Session().commit()
68 else:
69 print 'nothing done exiting...'
70 sys.exit(0)
71
72 def update_parser(self):
73 self.parser.add_option(
74 '--show',
75 action='store_true',
76 dest='show',
77 help=("show existing cache keys with together with status")
78 )
79
80 self.parser.add_option(
81 '--cleanup',
82 action="store_true",
83 dest="cleanup",
84 help="cleanup existing cache keys"
85 )
@@ -135,20 +135,20 b''
135 <li>${h.link_to(_('Lock'), h.url('toggle_locking',repo_name=c.repo_name),class_='locking_add')}</li>
135 <li>${h.link_to(_('Lock'), h.url('toggle_locking',repo_name=c.repo_name),class_='locking_add')}</li>
136 %endif
136 %endif
137 %endif
137 %endif
138 ## TODO: this check feels wrong, it would be better to have a check for permissions
138 ## TODO: this check feels wrong, it would be better to have a check for permissions
139 ## also it feels like a job for the controller
139 ## also it feels like a job for the controller
140 %if c.rhodecode_user.username != 'default':
140 %if c.rhodecode_user.username != 'default':
141 <li>
141 <li>
142 <a class="${follow_class()}" onclick="javascript:toggleFollowingRepo(this,${c.rhodecode_db_repo.repo_id},'${str(h.get_token())}');">
142 <a class="${follow_class()}" onclick="javascript:toggleFollowingRepo(this,${c.rhodecode_db_repo.repo_id},'${str(h.get_token())}');">
143 <span class="show-follow">${_('Follow')}</span>
143 <span class="show-follow">${_('Follow')}</span>
144 <span class="show-following">${_('Unfollow')}</span>
144 <span class="show-following">${_('Unfollow')}</span>
145 </a>
145 </a>
146 </li>
146 </li>
147 <li><a href="${h.url('repo_fork_home',repo_name=c.repo_name)}" class="fork">${_('Fork')}</a></li>
147 <li><a href="${h.url('repo_fork_home',repo_name=c.repo_name)}" class="fork">${_('Fork')}</a></li>
148 %if h.is_hg(c.rhodecode_repo):
148 %if h.is_hg(c.rhodecode_repo):
149 <li><a href="${h.url('pullrequest_home',repo_name=c.repo_name)}" class="pull-request">${_('Create Pull Request')}</a></li>
149 <li><a href="${h.url('pullrequest_home',repo_name=c.repo_name)}" class="pull-request">${_('Create Pull Request')}</a></li>
150 %endif
150 %endif
151 %endif
151 %endif
152 </ul>
152 </ul>
153 </li>
153 </li>
154 <li ${is_current('showpullrequest')}>
154 <li ${is_current('showpullrequest')}>
@@ -164,6 +164,7 b' setup('
164 update-repoinfo=rhodecode.lib.paster_commands.update_repoinfo:Command
164 update-repoinfo=rhodecode.lib.paster_commands.update_repoinfo:Command
165 make-rcext=rhodecode.lib.paster_commands.make_rcextensions:Command
165 make-rcext=rhodecode.lib.paster_commands.make_rcextensions:Command
166 repo-scan=rhodecode.lib.paster_commands.repo_scan:Command
166 repo-scan=rhodecode.lib.paster_commands.repo_scan:Command
167 cache-keys=rhodecode.lib.paster_commands.cache_keys:Command
167 make-index=rhodecode.lib.indexers:MakeIndex
168 make-index=rhodecode.lib.indexers:MakeIndex
168 upgrade-db=rhodecode.lib.dbmigrate:UpgradeDb
169 upgrade-db=rhodecode.lib.dbmigrate:UpgradeDb
169 celeryd=rhodecode.lib.celerypylons.commands:CeleryDaemonCommand
170 celeryd=rhodecode.lib.celerypylons.commands:CeleryDaemonCommand
General Comments 0
You need to be logged in to leave comments. Login now