Mercurial > kallithea
diff rhodecode/model/db.py @ 2356:2da7b5984ae5 beta
typo fix + code garden
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 28 May 2012 23:31:17 +0200 |
parents | 90e06f53af8c |
children | ea079c9b62b5 e87c6aa9c5e7 |
line wrap: on
line diff
--- a/rhodecode/model/db.py Mon May 28 16:52:13 2012 +0200 +++ b/rhodecode/model/db.py Mon May 28 23:31:17 2012 +0200 @@ -27,6 +27,7 @@ import logging import datetime import traceback +import hashlib from collections import defaultdict from sqlalchemy import * @@ -43,9 +44,8 @@ safe_unicode from rhodecode.lib.compat import json from rhodecode.lib.caching_query import FromCache +from rhodecode.model.meta import Base, Session -from rhodecode.model.meta import Base, Session -import hashlib URL_SEP = '/' log = logging.getLogger(__name__) @@ -152,11 +152,12 @@ return safe_str(self.__unicode__()) return '<DB:%s>' % (self.__class__.__name__) + class RhodeCodeSetting(Base, BaseModel): __tablename__ = 'rhodecode_settings' __table_args__ = ( UniqueConstraint('app_settings_name'), - {'extend_existing': True, 'mysql_engine':'InnoDB', + {'extend_existing': True, 'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'} ) app_settings_id = Column("app_settings_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) @@ -222,7 +223,7 @@ .filter(cls.app_settings_name.startswith('ldap_')).all() fd = {} for row in ret: - fd.update({row.app_settings_name:row.app_settings_value}) + fd.update({row.app_settings_name: row.app_settings_value}) return fd @@ -231,7 +232,7 @@ __tablename__ = 'rhodecode_ui' __table_args__ = ( UniqueConstraint('ui_key'), - {'extend_existing': True, 'mysql_engine':'InnoDB', + {'extend_existing': True, 'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'} ) @@ -282,7 +283,7 @@ __tablename__ = 'users' __table_args__ = ( UniqueConstraint('username'), UniqueConstraint('email'), - {'extend_existing': True, 'mysql_engine':'InnoDB', + {'extend_existing': True, 'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'} ) user_id = Column("user_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) @@ -404,7 +405,7 @@ class UserLog(Base, BaseModel): __tablename__ = 'user_logs' __table_args__ = ( - {'extend_existing': True, 'mysql_engine':'InnoDB', + {'extend_existing': True, 'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}, ) user_log_id = Column("user_log_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) @@ -426,7 +427,7 @@ class UsersGroup(Base, BaseModel): __tablename__ = 'users_groups' __table_args__ = ( - {'extend_existing': True, 'mysql_engine':'InnoDB', + {'extend_existing': True, 'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}, ) @@ -468,7 +469,7 @@ class UsersGroupMember(Base, BaseModel): __tablename__ = 'users_groups_members' __table_args__ = ( - {'extend_existing': True, 'mysql_engine':'InnoDB', + {'extend_existing': True, 'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}, ) @@ -488,7 +489,7 @@ __tablename__ = 'repositories' __table_args__ = ( UniqueConstraint('repo_name'), - {'extend_existing': True, 'mysql_engine':'InnoDB', + {'extend_existing': True, 'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}, ) @@ -704,7 +705,7 @@ # get using prefilled cache_map invalidate_repo = cache_map[self.repo_name] if invalidate_repo: - invalidate_repo = (None if invalidate_repo.cache_active + invalidate_repo = (None if invalidate_repo.cache_active else invalidate_repo) else: # get from invalidate @@ -747,7 +748,7 @@ __table_args__ = ( UniqueConstraint('group_name', 'group_parent_id'), CheckConstraint('group_id != group_parent_id'), - {'extend_existing': True, 'mysql_engine':'InnoDB', + {'extend_existing': True, 'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}, ) __mapper_args__ = {'order_by': 'group_name'} @@ -876,7 +877,7 @@ class Permission(Base, BaseModel): __tablename__ = 'permissions' __table_args__ = ( - {'extend_existing': True, 'mysql_engine':'InnoDB', + {'extend_existing': True, 'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}, ) permission_id = Column("permission_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) @@ -915,7 +916,7 @@ __tablename__ = 'repo_to_perm' __table_args__ = ( UniqueConstraint('user_id', 'repository_id', 'permission_id'), - {'extend_existing': True, 'mysql_engine':'InnoDB', + {'extend_existing': True, 'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'} ) repo_to_perm_id = Column("repo_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) @@ -944,7 +945,7 @@ __tablename__ = 'user_to_perm' __table_args__ = ( UniqueConstraint('user_id', 'permission_id'), - {'extend_existing': True, 'mysql_engine':'InnoDB', + {'extend_existing': True, 'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'} ) user_to_perm_id = Column("user_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) @@ -959,7 +960,7 @@ __tablename__ = 'users_group_repo_to_perm' __table_args__ = ( UniqueConstraint('repository_id', 'users_group_id', 'permission_id'), - {'extend_existing': True, 'mysql_engine':'InnoDB', + {'extend_existing': True, 'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'} ) 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 @@ __tablename__ = 'users_group_to_perm' __table_args__ = ( UniqueConstraint('users_group_id', 'permission_id',), - {'extend_existing': True, 'mysql_engine':'InnoDB', + {'extend_existing': True, 'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'} ) 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 @@ __tablename__ = 'user_repo_group_to_perm' __table_args__ = ( UniqueConstraint('user_id', 'group_id', 'permission_id'), - {'extend_existing': True, 'mysql_engine':'InnoDB', + {'extend_existing': True, 'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'} ) @@ -1021,7 +1022,7 @@ __tablename__ = 'users_group_repo_group_to_perm' __table_args__ = ( UniqueConstraint('users_group_id', 'group_id'), - {'extend_existing': True, 'mysql_engine':'InnoDB', + {'extend_existing': True, 'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'} ) @@ -1039,7 +1040,7 @@ __tablename__ = 'statistics' __table_args__ = ( UniqueConstraint('repository_id'), - {'extend_existing': True, 'mysql_engine':'InnoDB', + {'extend_existing': True, 'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'} ) stat_id = Column("stat_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) @@ -1057,7 +1058,7 @@ __table_args__ = ( UniqueConstraint('user_id', 'follows_repository_id'), UniqueConstraint('user_id', 'follows_user_id'), - {'extend_existing': True, 'mysql_engine':'InnoDB', + {'extend_existing': True, 'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'} ) @@ -1082,7 +1083,7 @@ __table_args__ = ( UniqueConstraint('cache_key'), Index('key_idx', 'cache_key'), - {'extend_existing': True, 'mysql_engine':'InnoDB', + {'extend_existing': True, 'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}, ) cache_id = Column("cache_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) @@ -1128,7 +1129,7 @@ try: inv_obj = CacheInvalidation(key, org_key) Session.add(inv_obj) - #Session.commit() + Session.commit() except Exception: log.error(traceback.format_exc()) Session.rollback() @@ -1194,7 +1195,7 @@ fixkey = kwargs.get('fixkey') if fixkey: del kwargs['fixkey'] - self.fixkey = fixkey + self.fixkey = fixkey super(cachemapdict, self).__init__(*args, **kwargs) def __getattr__(self, name): @@ -1223,7 +1224,7 @@ class ChangesetComment(Base, BaseModel): __tablename__ = 'changeset_comments' __table_args__ = ( - {'extend_existing': True, 'mysql_engine':'InnoDB', + {'extend_existing': True, 'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}, ) comment_id = Column('comment_id', Integer(), nullable=False, primary_key=True) @@ -1255,7 +1256,7 @@ class Notification(Base, BaseModel): __tablename__ = 'notifications' __table_args__ = ( - {'extend_existing': True, 'mysql_engine':'InnoDB', + {'extend_existing': True, 'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}, ) @@ -1310,7 +1311,7 @@ __tablename__ = 'user_to_notification' __table_args__ = ( UniqueConstraint('user_id', 'notification_id'), - {'extend_existing': True, 'mysql_engine':'InnoDB', + {'extend_existing': True, 'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'} ) user_id = Column('user_id', Integer(), ForeignKey('users.user_id'), primary_key=True) @@ -1330,7 +1331,7 @@ class DbMigrateVersion(Base, BaseModel): __tablename__ = 'db_migrate_version' __table_args__ = ( - {'extend_existing': True, 'mysql_engine':'InnoDB', + {'extend_existing': True, 'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}, ) repository_id = Column('repository_id', String(250), primary_key=True)