def _register_attribute(self, compare_function, copy_function, mutable_scalars, comparator_factory, callable_=None, proxy_property=None, active_history=False): self.logger.info("%s register managed attribute" % self) attribute_ext = util.to_list(self.parent_property.extension) or [] if self.key in self.parent._validators: attribute_ext.append(mapperutil.Validator(self.key, self.parent._validators[self.key])) for mapper in self.parent.polymorphic_iterator(): if (mapper is self.parent or not mapper.concrete) and mapper.has_property(self.key): sessionlib.register_attribute( mapper.class_, self.key, uselist=False, useobject=False, copy_function=copy_function, compare_function=compare_function, mutable_scalars=mutable_scalars, comparator=comparator_factory(self.parent_property, mapper), parententity=mapper, callable_=callable_, extension=attribute_ext, proxy_property=proxy_property, active_history=active_history )
def _handle_property(instance, name): mapper = instance.__mapper__ if (mapper.has_property(name) or hasattr(instance.__class__, name) or not hasattr(instance, '_sa_instance_state') or 'AssociationProxy' in name): return False else: return True
def _parent_mapper_has_property(cls, cls_bases, k): if len(cls_bases) == 0 and cls.__orig__ is cls_bases[0]: return False for b in cls_bases: mapper = b.Attributes.sqla_mapper if mapper is not None and mapper.has_property(k): # print(" Skipping mapping field", "%s.%s" % (cls.__name__, k), # "because parent mapper from", b.__name__, "already has it") return True # print("NOT skipping mapping field", "%s.%s" % (cls.__name__, k)) return False
def _register_attribute(strategy, useobject, compare_function=None, typecallable=None, copy_function=None, mutable_scalars=False, uselist=False, callable_=None, proxy_property=None, active_history=False, impl_class=None, **kw): prop = strategy.parent_property attribute_ext = util.to_list(prop.extension) or [] if getattr(prop, 'backref', None): attribute_ext.append(prop.backref.extension) if prop.key in prop.parent._validators: attribute_ext.append( mapperutil.Validator(prop.key, prop.parent._validators[prop.key])) if useobject: attribute_ext.append(sessionlib.UOWEventHandler(prop.key)) for mapper in prop.parent.polymorphic_iterator(): if (mapper is prop.parent or not mapper.concrete) and mapper.has_property(prop.key): attributes.register_attribute_impl( mapper.class_, prop.key, parent_token=prop, mutable_scalars=mutable_scalars, uselist=uselist, copy_function=copy_function, compare_function=compare_function, useobject=useobject, extension=attribute_ext, trackparent=useobject, typecallable=typecallable, callable_=callable_, active_history=active_history, impl_class=impl_class, **kw)