ref.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:OmMongo 作者: bapakode 项目源码 文件源码
def validate_unwrap(self, value, session=None):
        ''' Validates that the DBRef is valid as well as can be done without
            retrieving it.
        '''
        if not isinstance(value, DBRef):
            self._fail_validation_type(value, DBRef)
        if self.type:
            expected = self.type.type.get_collection_name()
            got = value.collection
            if expected != got:
                self._fail_validation(value, '''Wrong collection for reference: '''
                                      '''got "%s" instead of "%s" ''' % (got, expected))
        if self.db_required and not value.database:
            self._fail_validation(value, 'db_required=True, but not database specified')
        if self.db and value.database and self.db != value.database:
            self._fail_validation(value, '''Wrong database for reference: '''
                                  ''' got "%s" instead of "%s" ''' % (value.database, self.db) )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号