changeset 2809:070d2eacd48b beta

Show cache keys in admin settings of repository
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 05 Sep 2012 22:40:07 +0200
parents 3a007d806f0f
children 4a5c56da2603
files rhodecode/lib/utils.py rhodecode/model/db.py rhodecode/templates/admin/repos/repo_edit.html
diffstat 3 files changed, 46 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/lib/utils.py	Wed Sep 05 22:09:25 2012 +0200
+++ b/rhodecode/lib/utils.py	Wed Sep 05 22:40:07 2012 +0200
@@ -446,6 +446,7 @@
         # during starting install all cache keys for all repositories in the
         # system, this will register all repos and multiple instances
         key, _prefix, _org_key = CacheInvalidation._get_key(name)
+        log.debug("Creating cache key for %s instance_id:`%s`" % (name, _prefix))
         CacheInvalidation._get_or_create_key(key, _prefix, _org_key, commit=False)
     sa.commit()
     removed = []
--- a/rhodecode/model/db.py	Wed Sep 05 22:09:25 2012 +0200
+++ b/rhodecode/model/db.py	Wed Sep 05 22:40:07 2012 +0200
@@ -746,6 +746,16 @@
         p += self.repo_name.split(Repository.url_sep())
         return os.path.join(*p)
 
+    @property
+    def cache_keys(self):
+        """
+        Returns associated cache keys for that repo
+        """
+        return CacheInvalidation.query()\
+            .filter(CacheInvalidation.cache_args == self.repo_name)\
+            .order_by(CacheInvalidation.cache_key)\
+            .all()
+
     def get_new_name(self, repo_name):
         """
         returns new full repository name based on assigned group and new new
@@ -1402,6 +1412,13 @@
         return u"<%s('%s:%s')>" % (self.__class__.__name__,
                                   self.cache_id, self.cache_key)
 
+    @property
+    def prefix(self):
+        _split = self.cache_key.split(self.cache_args, 1)
+        if _split and len(_split) == 2:
+            return _split[0]
+        return ''
+
     @classmethod
     def clear_cache(cls):
         cls.query().delete()
--- a/rhodecode/templates/admin/repos/repo_edit.html	Wed Sep 05 22:09:25 2012 +0200
+++ b/rhodecode/templates/admin/repos/repo_edit.html	Wed Sep 05 22:40:07 2012 +0200
@@ -188,6 +188,20 @@
         <div class="form">
            <div class="fields">
                ${h.submit('reset_cache_%s' % c.repo_info.repo_name,_('Invalidate repository cache'),class_="ui-btn",onclick="return confirm('"+_('Confirm to invalidate repository cache')+"');")}
+              <div class="field" style="border:none;color:#888">
+              <ul>
+                  <li>${_('Manually invalidate cache for this repository. On first access repository will be cached again')}
+                  </li>
+              </ul>
+              </div>              
+              <div class="field" style="border:none;">
+                ${_('List of cached values')}
+                  <ul>
+                  %for cache in c.repo_info.cache_keys:
+                      <li>INSTANCE ID:${cache.prefix or '-'} ${cache.cache_args} CACHED: ${h.bool2icon(cache.cache_active)}</li>
+                  %endfor
+                  </ul>
+              </div>                     
            </div>
         </div>
         ${h.end_form()}
@@ -195,20 +209,20 @@
         <h3>${_('Public journal')}</h3>
         ${h.form(url('repo_public_journal', repo_name=c.repo_info.repo_name),method='put')}
         <div class="form">
-                ${h.hidden('auth_token',str(h.get_token()))}
-                <div class="field">
-                %if c.in_public_journal:
-                    ${h.submit('set_public_%s' % c.repo_info.repo_name,_('Remove from public journal'),class_="ui-btn")}
-                %else:
-		            ${h.submit('set_public_%s' % c.repo_info.repo_name,_('Add to public journal'),class_="ui-btn")}
-		        %endif
-                </div>
-               <div class="field" style="border:none;color:#888">
-               <ul>
-                    <li>${_('All actions made on this repository will be accessible to everyone in public journal')}
-                    </li>
-               </ul>
-               </div>
+          ${h.hidden('auth_token',str(h.get_token()))}
+          <div class="field">
+          %if c.in_public_journal:
+            ${h.submit('set_public_%s' % c.repo_info.repo_name,_('Remove from public journal'),class_="ui-btn")}
+          %else:
+            ${h.submit('set_public_%s' % c.repo_info.repo_name,_('Add to public journal'),class_="ui-btn")}
+          %endif
+          </div>
+         <div class="field" style="border:none;color:#888">
+         <ul>
+              <li>${_('All actions made on this repository will be accessible to everyone in public journal')}
+              </li>
+         </ul>
+         </div>
         </div>
         ${h.end_form()}