Python sqlalchemy.orm.mapper.class_() Examples
The following are 30
code examples of sqlalchemy.orm.mapper.class_().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sqlalchemy.orm.mapper
, or try the search function
.
Example #1
Source File: util.py From jbox with MIT License | 6 votes |
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))
Example #2
Source File: util.py From stdm with GNU General Public License v2.0 | 6 votes |
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))
Example #3
Source File: util.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
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))
Example #4
Source File: util.py From moviegrabber with GNU General Public License v3.0 | 6 votes |
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))
Example #5
Source File: util.py From pyRevit with GNU General Public License v3.0 | 6 votes |
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))
Example #6
Source File: util.py From sqlalchemy with MIT License | 5 votes |
def _reconstitute_from_aliased_insp(cls, aliased_insp): obj = cls.__new__(cls) obj.__name__ = "AliasedClass_%s" % aliased_insp.mapper.class_.__name__ obj._aliased_insp = aliased_insp return obj
Example #7
Source File: util.py From android_universal with MIT License | 5 votes |
def __repr__(self): if self.with_polymorphic_mappers: with_poly = "(%s)" % ", ".join( mp.class_.__name__ for mp in self.with_polymorphic_mappers) else: with_poly = "" return '<AliasedInsp at 0x%x; %s%s>' % ( id(self), self.class_.__name__, with_poly)
Example #8
Source File: util.py From sqlalchemy with MIT License | 5 votes |
def class_(self): """Return the mapped class ultimately represented by this :class:`.AliasedInsp`.""" return self.mapper.class_
Example #9
Source File: util.py From sqlalchemy with MIT License | 5 votes |
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)
Example #10
Source File: util.py From sqlalchemy with MIT License | 5 votes |
def __str__(self): if self._is_with_polymorphic: return "with_polymorphic(%s, [%s])" % ( self._target.__name__, ", ".join( mp.class_.__name__ for mp in self.with_polymorphic_mappers if mp is not self.mapper ), ) else: return "aliased(%s)" % (self._target.__name__,)
Example #11
Source File: util.py From sqlalchemy with MIT License | 5 votes |
def with_parent(instance, prop, from_entity=None): """Create filtering criterion that relates this query's primary entity to the given related instance, using established :func:`_orm.relationship()` configuration. The SQL rendered is the same as that rendered when a lazy loader would fire off from the given parent on that attribute, meaning that the appropriate state is taken from the parent object in Python without the need to render joins to the parent table in the rendered statement. :param instance: An instance which has some :func:`_orm.relationship`. :param property: String property name, or class-bound attribute, which indicates what relationship from the instance should be used to reconcile the parent/child relationship. :param from_entity: Entity in which to consider as the left side. This defaults to the "zero" entity of the :class:`_query.Query` itself. .. versionadded:: 1.2 """ if isinstance(prop, util.string_types): mapper = object_mapper(instance) prop = getattr(mapper.class_, prop).property elif isinstance(prop, attributes.QueryableAttribute): prop = prop.property return prop._with_parent(instance, from_entity=from_entity)
Example #12
Source File: util.py From jarvis with GNU General Public License v2.0 | 5 votes |
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__
Example #13
Source File: util.py From jarvis with GNU General Public License v2.0 | 5 votes |
def __init__(self, entity, mapper, selectable, name, with_polymorphic_mappers, polymorphic_on, _base_alias, _use_mapper_path, adapt_on_names, represents_outer_join): 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.represents_outer_join = represents_outer_join 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))
Example #14
Source File: util.py From jarvis with GNU General Public License v2.0 | 5 votes |
def class_(self): """Return the mapped class ultimately represented by this :class:`.AliasedInsp`.""" return self.mapper.class_
Example #15
Source File: util.py From jarvis with GNU General Public License v2.0 | 5 votes |
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)
Example #16
Source File: util.py From jarvis with GNU General Public License v2.0 | 5 votes |
def __repr__(self): if self.with_polymorphic_mappers: with_poly = "(%s)" % ", ".join( mp.class_.__name__ for mp in self.with_polymorphic_mappers) else: with_poly = "" return '<AliasedInsp at 0x%x; %s%s>' % ( id(self), self.class_.__name__, with_poly)
Example #17
Source File: util.py From moviegrabber with GNU General Public License v3.0 | 5 votes |
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): 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 ) self.__name__ = 'AliasedClass_%s' % mapper.class_.__name__
Example #18
Source File: util.py From moviegrabber with GNU General Public License v3.0 | 5 votes |
def class_(self): """Return the mapped class ultimately represented by this :class:`.AliasedInsp`.""" return self.mapper.class_
Example #19
Source File: util.py From moviegrabber with GNU General Public License v3.0 | 5 votes |
def _entity_for_mapper(self, mapper): self_poly = self.with_polymorphic_mappers if mapper in self_poly: 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)
Example #20
Source File: util.py From moviegrabber with GNU General Public License v3.0 | 5 votes |
def __repr__(self): return '<AliasedInsp at 0x%x; %s>' % ( id(self), self.class_.__name__)
Example #21
Source File: util.py From android_universal with MIT License | 5 votes |
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__
Example #22
Source File: util.py From android_universal with MIT License | 5 votes |
def __init__(self, entity, mapper, selectable, name, with_polymorphic_mappers, polymorphic_on, _base_alias, _use_mapper_path, adapt_on_names, represents_outer_join): 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.represents_outer_join = represents_outer_join 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))
Example #23
Source File: util.py From android_universal with MIT License | 5 votes |
def class_(self): """Return the mapped class ultimately represented by this :class:`.AliasedInsp`.""" return self.mapper.class_
Example #24
Source File: util.py From android_universal with MIT License | 5 votes |
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)
Example #25
Source File: util.py From jbox with MIT License | 5 votes |
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): 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 ) self.__name__ = 'AliasedClass_%s' % mapper.class_.__name__
Example #26
Source File: util.py From planespotter with MIT License | 5 votes |
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)
Example #27
Source File: util.py From jbox with MIT License | 5 votes |
def class_(self): """Return the mapped class ultimately represented by this :class:`.AliasedInsp`.""" return self.mapper.class_
Example #28
Source File: util.py From jbox with MIT License | 5 votes |
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)
Example #29
Source File: util.py From jbox with MIT License | 5 votes |
def __repr__(self): if self.with_polymorphic_mappers: with_poly = "(%s)" % ", ".join( mp.class_.__name__ for mp in self.with_polymorphic_mappers) else: with_poly = "" return '<AliasedInsp at 0x%x; %s%s>' % ( id(self), self.class_.__name__, with_poly)
Example #30
Source File: util.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
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): 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 ) self.__name__ = 'AliasedClass_%s' % mapper.class_.__name__