Show More
@@ -27,6 +27,7 b' import os' | |||
|
27 | 27 | import logging |
|
28 | 28 | import datetime |
|
29 | 29 | import traceback |
|
30 | import hashlib | |
|
30 | 31 | from collections import defaultdict |
|
31 | 32 | |
|
32 | 33 | from sqlalchemy import * |
@@ -43,9 +44,8 b' from rhodecode.lib.utils2 import str2boo' | |||
|
43 | 44 | safe_unicode |
|
44 | 45 | from rhodecode.lib.compat import json |
|
45 | 46 | from rhodecode.lib.caching_query import FromCache |
|
47 | from rhodecode.model.meta import Base, Session | |
|
46 | 48 | |
|
47 | from rhodecode.model.meta import Base, Session | |
|
48 | import hashlib | |
|
49 | 49 | |
|
50 | 50 | URL_SEP = '/' |
|
51 | 51 | log = logging.getLogger(__name__) |
@@ -152,11 +152,12 b' class BaseModel(object):' | |||
|
152 | 152 | return safe_str(self.__unicode__()) |
|
153 | 153 | return '<DB:%s>' % (self.__class__.__name__) |
|
154 | 154 | |
|
155 | ||
|
155 | 156 | class RhodeCodeSetting(Base, BaseModel): |
|
156 | 157 | __tablename__ = 'rhodecode_settings' |
|
157 | 158 | __table_args__ = ( |
|
158 | 159 | UniqueConstraint('app_settings_name'), |
|
159 | {'extend_existing': True, 'mysql_engine':'InnoDB', | |
|
160 | {'extend_existing': True, 'mysql_engine': 'InnoDB', | |
|
160 | 161 | 'mysql_charset': 'utf8'} |
|
161 | 162 | ) |
|
162 | 163 | app_settings_id = Column("app_settings_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) |
@@ -222,7 +223,7 b' class RhodeCodeSetting(Base, BaseModel):' | |||
|
222 | 223 | .filter(cls.app_settings_name.startswith('ldap_')).all() |
|
223 | 224 | fd = {} |
|
224 | 225 | for row in ret: |
|
225 | fd.update({row.app_settings_name:row.app_settings_value}) | |
|
226 | fd.update({row.app_settings_name: row.app_settings_value}) | |
|
226 | 227 | |
|
227 | 228 | return fd |
|
228 | 229 | |
@@ -231,7 +232,7 b' class RhodeCodeUi(Base, BaseModel):' | |||
|
231 | 232 | __tablename__ = 'rhodecode_ui' |
|
232 | 233 | __table_args__ = ( |
|
233 | 234 | UniqueConstraint('ui_key'), |
|
234 | {'extend_existing': True, 'mysql_engine':'InnoDB', | |
|
235 | {'extend_existing': True, 'mysql_engine': 'InnoDB', | |
|
235 | 236 | 'mysql_charset': 'utf8'} |
|
236 | 237 | ) |
|
237 | 238 | |
@@ -282,7 +283,7 b' class User(Base, BaseModel):' | |||
|
282 | 283 | __tablename__ = 'users' |
|
283 | 284 | __table_args__ = ( |
|
284 | 285 | UniqueConstraint('username'), UniqueConstraint('email'), |
|
285 | {'extend_existing': True, 'mysql_engine':'InnoDB', | |
|
286 | {'extend_existing': True, 'mysql_engine': 'InnoDB', | |
|
286 | 287 | 'mysql_charset': 'utf8'} |
|
287 | 288 | ) |
|
288 | 289 | user_id = Column("user_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) |
@@ -404,7 +405,7 b' class User(Base, BaseModel):' | |||
|
404 | 405 | class UserLog(Base, BaseModel): |
|
405 | 406 | __tablename__ = 'user_logs' |
|
406 | 407 | __table_args__ = ( |
|
407 | {'extend_existing': True, 'mysql_engine':'InnoDB', | |
|
408 | {'extend_existing': True, 'mysql_engine': 'InnoDB', | |
|
408 | 409 | 'mysql_charset': 'utf8'}, |
|
409 | 410 | ) |
|
410 | 411 | user_log_id = Column("user_log_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) |
@@ -426,7 +427,7 b' class UserLog(Base, BaseModel):' | |||
|
426 | 427 | class UsersGroup(Base, BaseModel): |
|
427 | 428 | __tablename__ = 'users_groups' |
|
428 | 429 | __table_args__ = ( |
|
429 | {'extend_existing': True, 'mysql_engine':'InnoDB', | |
|
430 | {'extend_existing': True, 'mysql_engine': 'InnoDB', | |
|
430 | 431 | 'mysql_charset': 'utf8'}, |
|
431 | 432 | ) |
|
432 | 433 | |
@@ -468,7 +469,7 b' class UsersGroup(Base, BaseModel):' | |||
|
468 | 469 | class UsersGroupMember(Base, BaseModel): |
|
469 | 470 | __tablename__ = 'users_groups_members' |
|
470 | 471 | __table_args__ = ( |
|
471 | {'extend_existing': True, 'mysql_engine':'InnoDB', | |
|
472 | {'extend_existing': True, 'mysql_engine': 'InnoDB', | |
|
472 | 473 | 'mysql_charset': 'utf8'}, |
|
473 | 474 | ) |
|
474 | 475 | |
@@ -488,7 +489,7 b' class Repository(Base, BaseModel):' | |||
|
488 | 489 | __tablename__ = 'repositories' |
|
489 | 490 | __table_args__ = ( |
|
490 | 491 | UniqueConstraint('repo_name'), |
|
491 | {'extend_existing': True, 'mysql_engine':'InnoDB', | |
|
492 | {'extend_existing': True, 'mysql_engine': 'InnoDB', | |
|
492 | 493 | 'mysql_charset': 'utf8'}, |
|
493 | 494 | ) |
|
494 | 495 | |
@@ -704,7 +705,7 b' class Repository(Base, BaseModel):' | |||
|
704 | 705 | # get using prefilled cache_map |
|
705 | 706 | invalidate_repo = cache_map[self.repo_name] |
|
706 | 707 | if invalidate_repo: |
|
707 |
invalidate_repo = (None if invalidate_repo.cache_active |
|
|
708 | invalidate_repo = (None if invalidate_repo.cache_active | |
|
708 | 709 | else invalidate_repo) |
|
709 | 710 | else: |
|
710 | 711 | # get from invalidate |
@@ -747,7 +748,7 b' class RepoGroup(Base, BaseModel):' | |||
|
747 | 748 | __table_args__ = ( |
|
748 | 749 | UniqueConstraint('group_name', 'group_parent_id'), |
|
749 | 750 | CheckConstraint('group_id != group_parent_id'), |
|
750 | {'extend_existing': True, 'mysql_engine':'InnoDB', | |
|
751 | {'extend_existing': True, 'mysql_engine': 'InnoDB', | |
|
751 | 752 | 'mysql_charset': 'utf8'}, |
|
752 | 753 | ) |
|
753 | 754 | __mapper_args__ = {'order_by': 'group_name'} |
@@ -876,7 +877,7 b' class RepoGroup(Base, BaseModel):' | |||
|
876 | 877 | class Permission(Base, BaseModel): |
|
877 | 878 | __tablename__ = 'permissions' |
|
878 | 879 | __table_args__ = ( |
|
879 | {'extend_existing': True, 'mysql_engine':'InnoDB', | |
|
880 | {'extend_existing': True, 'mysql_engine': 'InnoDB', | |
|
880 | 881 | 'mysql_charset': 'utf8'}, |
|
881 | 882 | ) |
|
882 | 883 | permission_id = Column("permission_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) |
@@ -915,7 +916,7 b' class UserRepoToPerm(Base, BaseModel):' | |||
|
915 | 916 | __tablename__ = 'repo_to_perm' |
|
916 | 917 | __table_args__ = ( |
|
917 | 918 | UniqueConstraint('user_id', 'repository_id', 'permission_id'), |
|
918 | {'extend_existing': True, 'mysql_engine':'InnoDB', | |
|
919 | {'extend_existing': True, 'mysql_engine': 'InnoDB', | |
|
919 | 920 | 'mysql_charset': 'utf8'} |
|
920 | 921 | ) |
|
921 | 922 | repo_to_perm_id = Column("repo_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) |
@@ -944,7 +945,7 b' class UserToPerm(Base, BaseModel):' | |||
|
944 | 945 | __tablename__ = 'user_to_perm' |
|
945 | 946 | __table_args__ = ( |
|
946 | 947 | UniqueConstraint('user_id', 'permission_id'), |
|
947 | {'extend_existing': True, 'mysql_engine':'InnoDB', | |
|
948 | {'extend_existing': True, 'mysql_engine': 'InnoDB', | |
|
948 | 949 | 'mysql_charset': 'utf8'} |
|
949 | 950 | ) |
|
950 | 951 | user_to_perm_id = Column("user_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) |
@@ -959,7 +960,7 b' class UsersGroupRepoToPerm(Base, BaseMod' | |||
|
959 | 960 | __tablename__ = 'users_group_repo_to_perm' |
|
960 | 961 | __table_args__ = ( |
|
961 | 962 | UniqueConstraint('repository_id', 'users_group_id', 'permission_id'), |
|
962 | {'extend_existing': True, 'mysql_engine':'InnoDB', | |
|
963 | {'extend_existing': True, 'mysql_engine': 'InnoDB', | |
|
963 | 964 | 'mysql_charset': 'utf8'} |
|
964 | 965 | ) |
|
965 | 966 | users_group_to_perm_id = Column("users_group_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) |
@@ -988,7 +989,7 b' class UsersGroupToPerm(Base, BaseModel):' | |||
|
988 | 989 | __tablename__ = 'users_group_to_perm' |
|
989 | 990 | __table_args__ = ( |
|
990 | 991 | UniqueConstraint('users_group_id', 'permission_id',), |
|
991 | {'extend_existing': True, 'mysql_engine':'InnoDB', | |
|
992 | {'extend_existing': True, 'mysql_engine': 'InnoDB', | |
|
992 | 993 | 'mysql_charset': 'utf8'} |
|
993 | 994 | ) |
|
994 | 995 | users_group_to_perm_id = Column("users_group_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) |
@@ -1003,7 +1004,7 b' class UserRepoGroupToPerm(Base, BaseMode' | |||
|
1003 | 1004 | __tablename__ = 'user_repo_group_to_perm' |
|
1004 | 1005 | __table_args__ = ( |
|
1005 | 1006 | UniqueConstraint('user_id', 'group_id', 'permission_id'), |
|
1006 | {'extend_existing': True, 'mysql_engine':'InnoDB', | |
|
1007 | {'extend_existing': True, 'mysql_engine': 'InnoDB', | |
|
1007 | 1008 | 'mysql_charset': 'utf8'} |
|
1008 | 1009 | ) |
|
1009 | 1010 | |
@@ -1021,7 +1022,7 b' class UsersGroupRepoGroupToPerm(Base, Ba' | |||
|
1021 | 1022 | __tablename__ = 'users_group_repo_group_to_perm' |
|
1022 | 1023 | __table_args__ = ( |
|
1023 | 1024 | UniqueConstraint('users_group_id', 'group_id'), |
|
1024 | {'extend_existing': True, 'mysql_engine':'InnoDB', | |
|
1025 | {'extend_existing': True, 'mysql_engine': 'InnoDB', | |
|
1025 | 1026 | 'mysql_charset': 'utf8'} |
|
1026 | 1027 | ) |
|
1027 | 1028 | |
@@ -1039,7 +1040,7 b' class Statistics(Base, BaseModel):' | |||
|
1039 | 1040 | __tablename__ = 'statistics' |
|
1040 | 1041 | __table_args__ = ( |
|
1041 | 1042 | UniqueConstraint('repository_id'), |
|
1042 | {'extend_existing': True, 'mysql_engine':'InnoDB', | |
|
1043 | {'extend_existing': True, 'mysql_engine': 'InnoDB', | |
|
1043 | 1044 | 'mysql_charset': 'utf8'} |
|
1044 | 1045 | ) |
|
1045 | 1046 | stat_id = Column("stat_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) |
@@ -1057,7 +1058,7 b' class UserFollowing(Base, BaseModel):' | |||
|
1057 | 1058 | __table_args__ = ( |
|
1058 | 1059 | UniqueConstraint('user_id', 'follows_repository_id'), |
|
1059 | 1060 | UniqueConstraint('user_id', 'follows_user_id'), |
|
1060 | {'extend_existing': True, 'mysql_engine':'InnoDB', | |
|
1061 | {'extend_existing': True, 'mysql_engine': 'InnoDB', | |
|
1061 | 1062 | 'mysql_charset': 'utf8'} |
|
1062 | 1063 | ) |
|
1063 | 1064 | |
@@ -1082,7 +1083,7 b' class CacheInvalidation(Base, BaseModel)' | |||
|
1082 | 1083 | __table_args__ = ( |
|
1083 | 1084 | UniqueConstraint('cache_key'), |
|
1084 | 1085 | Index('key_idx', 'cache_key'), |
|
1085 | {'extend_existing': True, 'mysql_engine':'InnoDB', | |
|
1086 | {'extend_existing': True, 'mysql_engine': 'InnoDB', | |
|
1086 | 1087 | 'mysql_charset': 'utf8'}, |
|
1087 | 1088 | ) |
|
1088 | 1089 | cache_id = Column("cache_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) |
@@ -1128,7 +1129,7 b' class CacheInvalidation(Base, BaseModel)' | |||
|
1128 | 1129 | try: |
|
1129 | 1130 | inv_obj = CacheInvalidation(key, org_key) |
|
1130 | 1131 | Session.add(inv_obj) |
|
1131 |
|
|
|
1132 | Session.commit() | |
|
1132 | 1133 | except Exception: |
|
1133 | 1134 | log.error(traceback.format_exc()) |
|
1134 | 1135 | Session.rollback() |
@@ -1194,7 +1195,7 b' class CacheInvalidation(Base, BaseModel)' | |||
|
1194 | 1195 | fixkey = kwargs.get('fixkey') |
|
1195 | 1196 | if fixkey: |
|
1196 | 1197 | del kwargs['fixkey'] |
|
1197 |
self.fixkey = fixkey |
|
|
1198 | self.fixkey = fixkey | |
|
1198 | 1199 | super(cachemapdict, self).__init__(*args, **kwargs) |
|
1199 | 1200 | |
|
1200 | 1201 | def __getattr__(self, name): |
@@ -1223,7 +1224,7 b' class CacheInvalidation(Base, BaseModel)' | |||
|
1223 | 1224 | class ChangesetComment(Base, BaseModel): |
|
1224 | 1225 | __tablename__ = 'changeset_comments' |
|
1225 | 1226 | __table_args__ = ( |
|
1226 | {'extend_existing': True, 'mysql_engine':'InnoDB', | |
|
1227 | {'extend_existing': True, 'mysql_engine': 'InnoDB', | |
|
1227 | 1228 | 'mysql_charset': 'utf8'}, |
|
1228 | 1229 | ) |
|
1229 | 1230 | comment_id = Column('comment_id', Integer(), nullable=False, primary_key=True) |
@@ -1255,7 +1256,7 b' class ChangesetComment(Base, BaseModel):' | |||
|
1255 | 1256 | class Notification(Base, BaseModel): |
|
1256 | 1257 | __tablename__ = 'notifications' |
|
1257 | 1258 | __table_args__ = ( |
|
1258 | {'extend_existing': True, 'mysql_engine':'InnoDB', | |
|
1259 | {'extend_existing': True, 'mysql_engine': 'InnoDB', | |
|
1259 | 1260 | 'mysql_charset': 'utf8'}, |
|
1260 | 1261 | ) |
|
1261 | 1262 | |
@@ -1310,7 +1311,7 b' class UserNotification(Base, BaseModel):' | |||
|
1310 | 1311 | __tablename__ = 'user_to_notification' |
|
1311 | 1312 | __table_args__ = ( |
|
1312 | 1313 | UniqueConstraint('user_id', 'notification_id'), |
|
1313 | {'extend_existing': True, 'mysql_engine':'InnoDB', | |
|
1314 | {'extend_existing': True, 'mysql_engine': 'InnoDB', | |
|
1314 | 1315 | 'mysql_charset': 'utf8'} |
|
1315 | 1316 | ) |
|
1316 | 1317 | user_id = Column('user_id', Integer(), ForeignKey('users.user_id'), primary_key=True) |
@@ -1330,7 +1331,7 b' class UserNotification(Base, BaseModel):' | |||
|
1330 | 1331 | class DbMigrateVersion(Base, BaseModel): |
|
1331 | 1332 | __tablename__ = 'db_migrate_version' |
|
1332 | 1333 | __table_args__ = ( |
|
1333 | {'extend_existing': True, 'mysql_engine':'InnoDB', | |
|
1334 | {'extend_existing': True, 'mysql_engine': 'InnoDB', | |
|
1334 | 1335 | 'mysql_charset': 'utf8'}, |
|
1335 | 1336 | ) |
|
1336 | 1337 | repository_id = Column('repository_id', String(250), primary_key=True) |
General Comments 0
You need to be logged in to leave comments.
Login now