changeset 2013:8530c3cd9d04 beta

fixed issue with hybrid property for ldap_active - some small fixes for cache_keys functions
author Marcin Kuzminski <marcin@python-works.com>
date Tue, 21 Feb 2012 20:09:18 +0200
parents ca39c02c7c3e
children 8ccac2b0fcf3
files rhodecode/model/db.py
diffstat 1 files changed, 16 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/model/db.py	Tue Feb 21 20:01:05 2012 +0200
+++ b/rhodecode/model/db.py	Tue Feb 21 20:09:18 2012 +0200
@@ -165,7 +165,7 @@
     @hybrid_property
     def app_settings_value(self):
         v = self._app_settings_value
-        if v == 'ldap_active':
+        if self.app_settings_name == 'ldap_active':
             v = str2bool(v)
         return v
 
@@ -446,6 +446,7 @@
         self.users_group_id = gr_id
         self.user_id = u_id
 
+
 class Repository(Base, BaseModel):
     __tablename__ = 'repositories'
     __table_args__ = (
@@ -1027,6 +1028,19 @@
                                   self.cache_id, self.cache_key)
 
     @classmethod
+    def _get_key(cls, key):
+        """
+        Wrapper for generating a key
+
+        :param key:
+        """
+        return "%s" % (key)
+
+    @classmethod
+    def get_by_key(cls, key):
+        return cls.query().filter(cls.cache_key == key).scalar()
+
+    @classmethod
     def invalidate(cls, key):
         """
         Returns Invalidation object if this given key should be invalidated
@@ -1071,8 +1085,7 @@
 
         :param key:
         """
-        inv_obj = CacheInvalidation.query()\
-            .filter(CacheInvalidation.cache_key == key).scalar()
+        inv_obj = cls.get_by_key(key)
         inv_obj.cache_active = True
         Session.add(inv_obj)
         Session.commit()