當前位置: 首頁>>代碼示例>>Python>>正文


Python mapper.with_polymorphic_mappers方法代碼示例

本文整理匯總了Python中sqlalchemy.orm.mapper.with_polymorphic_mappers方法的典型用法代碼示例。如果您正苦於以下問題:Python mapper.with_polymorphic_mappers方法的具體用法?Python mapper.with_polymorphic_mappers怎麽用?Python mapper.with_polymorphic_mappers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sqlalchemy.orm.mapper的用法示例。


在下文中一共展示了mapper.with_polymorphic_mappers方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from sqlalchemy.orm import mapper [as 別名]
# 或者: from sqlalchemy.orm.mapper import with_polymorphic_mappers [as 別名]
def __init__(self, entity, mapper, selectable, name,
                 with_polymorphic_mappers, polymorphic_on,
                 _base_alias, _use_mapper_path, adapt_on_names):
        self.entity = entity
        self.mapper = mapper
        self.selectable = selectable
        self.name = name
        self.with_polymorphic_mappers = with_polymorphic_mappers
        self.polymorphic_on = polymorphic_on
        self._base_alias = _base_alias or self
        self._use_mapper_path = _use_mapper_path

        self._adapter = sql_util.ColumnAdapter(
            selectable, equivalents=mapper._equivalent_columns,
            adapt_on_names=adapt_on_names, anonymize_labels=True)

        self._adapt_on_names = adapt_on_names
        self._target = mapper.class_

        for poly in self.with_polymorphic_mappers:
            if poly is not mapper:
                setattr(self.entity, poly.class_.__name__,
                        AliasedClass(poly.class_, selectable, base_alias=self,
                                     adapt_on_names=adapt_on_names,
                                     use_mapper_path=_use_mapper_path)) 
開發者ID:jpush,項目名稱:jbox,代碼行數:27,代碼來源:util.py

示例2: _entity_corresponds_to

# 需要導入模塊: from sqlalchemy.orm import mapper [as 別名]
# 或者: from sqlalchemy.orm.mapper import with_polymorphic_mappers [as 別名]
def _entity_corresponds_to(given, entity):
    """determine if 'given' corresponds to 'entity', in terms
    of an entity passed to Query that would match the same entity
    being referred to elsewhere in the query.

    """
    if entity.is_aliased_class:
        if given.is_aliased_class:
            if entity._base_alias is given._base_alias:
                return True
        return False
    elif given.is_aliased_class:
        if given._use_mapper_path:
            return entity in given.with_polymorphic_mappers
        else:
            return entity is given

    return entity.common_parent(given) 
開發者ID:yfauser,項目名稱:planespotter,代碼行數:20,代碼來源:util.py

示例3: __init__

# 需要導入模塊: from sqlalchemy.orm import mapper [as 別名]
# 或者: from sqlalchemy.orm.mapper import with_polymorphic_mappers [as 別名]
def __init__(self, entity, mapper, selectable, name,
                 with_polymorphic_mappers, polymorphic_on,
                 _base_alias, _use_mapper_path, adapt_on_names):
        self.entity = entity
        self.mapper = mapper
        self.selectable = selectable
        self.name = name
        self.with_polymorphic_mappers = with_polymorphic_mappers
        self.polymorphic_on = polymorphic_on
        self._base_alias = _base_alias or self
        self._use_mapper_path = _use_mapper_path

        self._adapter = sql_util.ClauseAdapter(
            selectable, equivalents=mapper._equivalent_columns,
            adapt_on_names=adapt_on_names)

        self._adapt_on_names = adapt_on_names
        self._target = mapper.class_

        for poly in self.with_polymorphic_mappers:
            if poly is not mapper:
                setattr(self.entity, poly.class_.__name__,
                        AliasedClass(poly.class_, selectable, base_alias=self,
                                     adapt_on_names=adapt_on_names,
                                     use_mapper_path=_use_mapper_path)) 
開發者ID:gltn,項目名稱:stdm,代碼行數:27,代碼來源:util.py

示例4: _entity_corresponds_to

# 需要導入模塊: from sqlalchemy.orm import mapper [as 別名]
# 或者: from sqlalchemy.orm.mapper import with_polymorphic_mappers [as 別名]
def _entity_corresponds_to(given, entity):
    """determine if 'given' corresponds to 'entity', in terms
    of an entity passed to Query that would match the same entity
    being referred to elsewhere in the query.

    """
    if entity.is_aliased_class:
        if given.is_aliased_class:
            if entity._base_alias() is given._base_alias():
                return True
        return False
    elif given.is_aliased_class:
        if given._use_mapper_path:
            return entity in given.with_polymorphic_mappers
        else:
            return entity is given

    return entity.common_parent(given) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:20,代碼來源:util.py

示例5: __init__

# 需要導入模塊: from sqlalchemy.orm import mapper [as 別名]
# 或者: from sqlalchemy.orm.mapper import with_polymorphic_mappers [as 別名]
def __init__(self, entity, mapper, selectable, name,
                    with_polymorphic_mappers, polymorphic_on,
                    _base_alias, _use_mapper_path, adapt_on_names):
        self.entity = entity
        self.mapper = mapper
        self.selectable = selectable
        self.name = name
        self.with_polymorphic_mappers = with_polymorphic_mappers
        self.polymorphic_on = polymorphic_on
        self._base_alias = _base_alias or self
        self._use_mapper_path = _use_mapper_path

        self._adapter = sql_util.ClauseAdapter(selectable,
                            equivalents=mapper._equivalent_columns,
                            adapt_on_names=adapt_on_names)

        self._adapt_on_names = adapt_on_names
        self._target = mapper.class_

        for poly in self.with_polymorphic_mappers:
            if poly is not mapper:
                setattr(self.entity, poly.class_.__name__,
                    AliasedClass(poly.class_, selectable, base_alias=self,
                            adapt_on_names=adapt_on_names,
                            use_mapper_path=_use_mapper_path)) 
開發者ID:binhex,項目名稱:moviegrabber,代碼行數:27,代碼來源:util.py

示例6: __getstate__

# 需要導入模塊: from sqlalchemy.orm import mapper [as 別名]
# 或者: from sqlalchemy.orm.mapper import with_polymorphic_mappers [as 別名]
def __getstate__(self):
        return {
            'entity': self.entity,
            'mapper': self.mapper,
            'alias': self.selectable,
            'name': self.name,
            'adapt_on_names': self._adapt_on_names,
            'with_polymorphic_mappers':
                self.with_polymorphic_mappers,
            'with_polymorphic_discriminator':
                self.polymorphic_on,
            'base_alias': self._base_alias,
            'use_mapper_path': self._use_mapper_path
        } 
開發者ID:jpush,項目名稱:jbox,代碼行數:16,代碼來源:util.py

示例7: __setstate__

# 需要導入模塊: from sqlalchemy.orm import mapper [as 別名]
# 或者: from sqlalchemy.orm.mapper import with_polymorphic_mappers [as 別名]
def __setstate__(self, state):
        self.__init__(
            state['entity'],
            state['mapper'],
            state['alias'],
            state['name'],
            state['with_polymorphic_mappers'],
            state['with_polymorphic_discriminator'],
            state['base_alias'],
            state['use_mapper_path'],
            state['adapt_on_names']
        ) 
開發者ID:jpush,項目名稱:jbox,代碼行數:14,代碼來源:util.py

示例8: _entity_for_mapper

# 需要導入模塊: from sqlalchemy.orm import mapper [as 別名]
# 或者: from sqlalchemy.orm.mapper import with_polymorphic_mappers [as 別名]
def _entity_for_mapper(self, mapper):
        self_poly = self.with_polymorphic_mappers
        if mapper in self_poly:
            if mapper is self.mapper:
                return self
            else:
                return getattr(
                    self.entity, mapper.class_.__name__)._aliased_insp
        elif mapper.isa(self.mapper):
            return self
        else:
            assert False, "mapper %s doesn't correspond to %s" % (
                mapper, self) 
開發者ID:jpush,項目名稱:jbox,代碼行數:15,代碼來源:util.py

示例9: __init__

# 需要導入模塊: from sqlalchemy.orm import mapper [as 別名]
# 或者: from sqlalchemy.orm.mapper import with_polymorphic_mappers [as 別名]
def __init__(self, cls, alias=None,
                 name=None,
                 flat=False,
                 adapt_on_names=False,
                 #  TODO: None for default here?
                 with_polymorphic_mappers=(),
                 with_polymorphic_discriminator=None,
                 base_alias=None,
                 use_mapper_path=False,
                 represents_outer_join=False):
        mapper = _class_to_mapper(cls)
        if alias is None:
            alias = mapper._with_polymorphic_selectable.alias(
                name=name, flat=flat)

        self._aliased_insp = AliasedInsp(
            self,
            mapper,
            alias,
            name,
            with_polymorphic_mappers
            if with_polymorphic_mappers
            else mapper.with_polymorphic_mappers,
            with_polymorphic_discriminator
            if with_polymorphic_discriminator is not None
            else mapper.polymorphic_on,
            base_alias,
            use_mapper_path,
            adapt_on_names,
            represents_outer_join
        )

        self.__name__ = 'AliasedClass_%s' % mapper.class_.__name__ 
開發者ID:yfauser,項目名稱:planespotter,代碼行數:35,代碼來源:util.py

示例10: __getstate__

# 需要導入模塊: from sqlalchemy.orm import mapper [as 別名]
# 或者: from sqlalchemy.orm.mapper import with_polymorphic_mappers [as 別名]
def __getstate__(self):
        return {
            'entity': self.entity,
            'mapper': self.mapper,
            'alias': self.selectable,
            'name': self.name,
            'adapt_on_names': self._adapt_on_names,
            'with_polymorphic_mappers':
                self.with_polymorphic_mappers,
            'with_polymorphic_discriminator':
                self.polymorphic_on,
            'base_alias': self._base_alias,
            'use_mapper_path': self._use_mapper_path,
            'represents_outer_join': self.represents_outer_join
        } 
開發者ID:yfauser,項目名稱:planespotter,代碼行數:17,代碼來源:util.py

示例11: __setstate__

# 需要導入模塊: from sqlalchemy.orm import mapper [as 別名]
# 或者: from sqlalchemy.orm.mapper import with_polymorphic_mappers [as 別名]
def __setstate__(self, state):
        self.__init__(
            state['entity'],
            state['mapper'],
            state['alias'],
            state['name'],
            state['with_polymorphic_mappers'],
            state['with_polymorphic_discriminator'],
            state['base_alias'],
            state['use_mapper_path'],
            state['adapt_on_names'],
            state['represents_outer_join']
        ) 
開發者ID:yfauser,項目名稱:planespotter,代碼行數:15,代碼來源:util.py

示例12: _entity_isa

# 需要導入模塊: from sqlalchemy.orm import mapper [as 別名]
# 或者: from sqlalchemy.orm.mapper import with_polymorphic_mappers [as 別名]
def _entity_isa(given, mapper):
    """determine if 'given' "is a" mapper, in terms of the given
    would load rows of type 'mapper'.

    """
    if given.is_aliased_class:
        return mapper in given.with_polymorphic_mappers or \
            given.mapper.isa(mapper)
    elif given.with_polymorphic_mappers:
        return mapper in given.with_polymorphic_mappers
    else:
        return given.isa(mapper) 
開發者ID:yfauser,項目名稱:planespotter,代碼行數:14,代碼來源:util.py


注:本文中的sqlalchemy.orm.mapper.with_polymorphic_mappers方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。