Mercurial > kallithea
comparison rhodecode/model/db.py @ 1818:cf51bbfb120e beta
auto white-space removal
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 29 Dec 2011 07:35:51 +0200 |
parents | 6c86c987cf93 |
children | 9451a569aee5 |
comparison
equal
deleted
inserted
replaced
1817:523b1011a625 | 1818:cf51bbfb120e |
---|---|
94 return class_mapper(cls).c.keys() | 94 return class_mapper(cls).c.keys() |
95 | 95 |
96 def get_dict(self, serialized=False): | 96 def get_dict(self, serialized=False): |
97 """ | 97 """ |
98 return dict with keys and values corresponding | 98 return dict with keys and values corresponding |
99 to this model data | 99 to this model data |
100 """ | 100 """ |
101 | 101 |
102 d = {} | 102 d = {} |
103 for k in self._get_keys(): | 103 for k in self._get_keys(): |
104 d[k] = getattr(self, k) | 104 d[k] = getattr(self, k) |
105 | 105 |
106 # also use __json__() if present to get additional fields | 106 # also use __json__() if present to get additional fields |
107 if hasattr(self, '__json__'): | 107 if hasattr(self, '__json__'): |
108 for k, val in self.__json__().iteritems(): | 108 for k, val in self.__json__().iteritems(): |
109 d[k] = val | 109 d[k] = val |
110 return d | 110 return d |
111 | 111 |
112 def get_appstruct(self): | 112 def get_appstruct(self): |
113 """return list with keys and values tupples corresponding | 113 """return list with keys and values tupples corresponding |
114 to this model data """ | 114 to this model data """ |
968 def invalidate(cls, key): | 968 def invalidate(cls, key): |
969 """ | 969 """ |
970 Returns Invalidation object if this given key should be invalidated | 970 Returns Invalidation object if this given key should be invalidated |
971 None otherwise. `cache_active = False` means that this cache | 971 None otherwise. `cache_active = False` means that this cache |
972 state is not valid and needs to be invalidated | 972 state is not valid and needs to be invalidated |
973 | 973 |
974 :param key: | 974 :param key: |
975 """ | 975 """ |
976 return cls.query()\ | 976 return cls.query()\ |
977 .filter(CacheInvalidation.cache_key == key)\ | 977 .filter(CacheInvalidation.cache_key == key)\ |
978 .filter(CacheInvalidation.cache_active == False)\ | 978 .filter(CacheInvalidation.cache_active == False)\ |
980 | 980 |
981 @classmethod | 981 @classmethod |
982 def set_invalidate(cls, key): | 982 def set_invalidate(cls, key): |
983 """ | 983 """ |
984 Mark this Cache key for invalidation | 984 Mark this Cache key for invalidation |
985 | 985 |
986 :param key: | 986 :param key: |
987 """ | 987 """ |
988 | 988 |
989 log.debug('marking %s for invalidation' % key) | 989 log.debug('marking %s for invalidation' % key) |
990 inv_obj = Session.query(cls)\ | 990 inv_obj = Session.query(cls)\ |
1004 | 1004 |
1005 @classmethod | 1005 @classmethod |
1006 def set_valid(cls, key): | 1006 def set_valid(cls, key): |
1007 """ | 1007 """ |
1008 Mark this cache key as active and currently cached | 1008 Mark this cache key as active and currently cached |
1009 | 1009 |
1010 :param key: | 1010 :param key: |
1011 """ | 1011 """ |
1012 inv_obj = CacheInvalidation.query()\ | 1012 inv_obj = CacheInvalidation.query()\ |
1013 .filter(CacheInvalidation.cache_key == key).scalar() | 1013 .filter(CacheInvalidation.cache_key == key).scalar() |
1014 inv_obj.cache_active = True | 1014 inv_obj.cache_active = True |
1035 @classmethod | 1035 @classmethod |
1036 def get_users(cls, revision): | 1036 def get_users(cls, revision): |
1037 """ | 1037 """ |
1038 Returns user associated with this changesetComment. ie those | 1038 Returns user associated with this changesetComment. ie those |
1039 who actually commented | 1039 who actually commented |
1040 | 1040 |
1041 :param cls: | 1041 :param cls: |
1042 :param revision: | 1042 :param revision: |
1043 """ | 1043 """ |
1044 return Session.query(User)\ | 1044 return Session.query(User)\ |
1045 .filter(cls.revision == revision)\ | 1045 .filter(cls.revision == revision)\ |
1118 __tablename__ = 'db_migrate_version' | 1118 __tablename__ = 'db_migrate_version' |
1119 __table_args__ = {'extend_existing':True} | 1119 __table_args__ = {'extend_existing':True} |
1120 repository_id = Column('repository_id', String(250), primary_key=True) | 1120 repository_id = Column('repository_id', String(250), primary_key=True) |
1121 repository_path = Column('repository_path', Text) | 1121 repository_path = Column('repository_path', Text) |
1122 version = Column('version', Integer) | 1122 version = Column('version', Integer) |
1123 |