old_contents: #!/usr/bin/env python
  # -*- coding: utf-8 -*-
  # @Time : 2017/5/29 2:22
  # @Author : BlackMatrix
  # @Site : https://github.com/blackmatrix7
  # @File : models.py
  # @Software: PyCharm
  from app.exts import db
  from app.database import ModelBase, ModelMixin
  
  __author__ = 'blackmatix'
  
  
  class Client(ModelBase, ModelMixin):
  
      __tablename__ = 'client'
  
      name = db.Column(db.String(40))
      description = db.Column(db.String(400))
      user_id = db.Column(db.ForeignKey('user.id'))
      client_id = db.Column(db.String(40),
                            primary_key=True)
      client_secret = db.Column(db.String(55),
                                unique=True,
                                index=True,
                                nullable=False)
      is_confidential = db.Column(db.Boolean)
  
      _redirect_uris = db.Column(db.Text)
      _default_scopes = db.Column(db.Text)
  
      @property
      def client_type(self):
          if self.is_confidential:
              return 'confidential'
          return 'public'
  
      @property
      def redirect_uris(self):
          if self._redirect_uris:
              return self._redirect_uris.split()
          return []
  
      @property
      def default_redirect_uri(self):
          return self.redirect_uris[0]
  
      @property
      def default_scopes(self):
          if self._default_scopes:
              return self._default_scopes.split()
          return []
  
  
  if __name__ == '__main__':
      pass
  
new_contents: #!/usr/bin/env python
  # -*- coding: utf-8 -*-
  # @Time : 2017/5/29 2:22
  # @Author : BlackMatrix
  # @Site : https://github.com/blackmatrix7
  # @File : models.py
  # @Software: PyCharm
  from app.exts import db
  from app.database import ModelBase, ModelMixin
  
  __author__ = 'blackmatrix'
  
  
  class Client(ModelBase, ModelMixin):
  
      __tablename__ = 'client'
  
      name = db.Column(db.String(40))
      description = db.Column(db.String(400))
      user_id = db.Column(db.ForeignKey('user.id'))
      client_id = db.Column(db.String(40),
                            primary_key=True)
      client_secret = db.Column(db.String(55),
                                unique=True,
                                index=True,
                                nullable=False)
      is_confidential = db.Column(db.Boolean)
  
      _redirect_uris = db.Column(db.Text)
      _default_scopes = db.Column(db.Text)
  
      @property
      def client_type(self):
          if self.is_confidential:
              return 'confidential'
          return 'public'
  
      @property
      def redirect_uris(self):
          if self._redirect_uris:
              return self._redirect_uris.split()
          return []
  
      @property
      def default_redirect_uri(self):
          return self.redirect_uris[0]
  
      @property
      def default_scopes(self):
          if self._default_scopes:
              return self._default_scopes.split()
          return []
  
  
  if __name__ == '__main__':
      pass
  
subject: 简化异常的处理方式，提高代码可读性