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