Python sqlalchemy.orm 模块,ColumnProperty() 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用sqlalchemy.orm.ColumnProperty()

项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
def primary_key_names(model):
    """Returns all the primary keys for a model."""
    return [key for key, field in inspect.getmembers(model)
            if isinstance(field, QueryableAttribute)
            and isinstance(field.property, ColumnProperty)
            and field.property.columns[0].primary_key]
项目:griffith    作者:Strit    | 项目源码 | 文件源码
def post_configure_attribute_07(self, class_, key, inst):
        """Add validators for any attributes that can be validated."""
        # SQLAlchemy >= 0.7 (using events)
        prop = inst.prop
        # Only interested in simple columns, not relations
        if isinstance(prop, ColumnProperty) and len(prop.columns) == 1:
            col = prop.columns[0]
            # if we have string column with a length, install a length validator
            if isinstance(col.type, String) and col.type.length:
                event.listen(inst, 'set', LengthValidator(col.name, col.type.length).set, retval=True)
项目:griffith    作者:Strit    | 项目源码 | 文件源码
def post_configure_attribute_pre_07(self, class_, key, inst):
        """Add validators for any attributes that can be validated."""
        # SQLAlchemy < 0.7 (using extensions)
        prop = inst.prop
        # Only interested in simple columns, not relations
        if isinstance(prop, ColumnProperty) and len(prop.columns) == 1:
            col = prop.columns[0]
            # if we have string column with a length, install a length validator
            if isinstance(col.type, String) and col.type.length:
                inst.impl.extensions.insert(0, LengthValidator(col.name, col.type.length))
项目:sqlalchemy-validation    作者:blazelibs    | 项目源码 | 文件源码
def _sav_column_names(self):
        return [p.key for p in self.__mapper__.iterate_properties
                if isinstance(p, saorm.ColumnProperty)]
项目:deb-python-sqlalchemy-utils    作者:openstack    | 项目源码 | 文件源码
def _column_to_property(self, column):
        if isinstance(column, hybrid_property):
            attr_key = column.__name__
            for key, attr in self.parent.all_orm_descriptors.items():
                if key == attr_key:
                    return attr
        else:
            for key, attr in self.parent.attrs.items():
                if isinstance(attr, ColumnProperty):
                    if attr.columns[0].name == column.name:
                        return attr