Example #1
0
def _register_attribute(
    strategy,
    mapper,
    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 useobject and prop.single_parent:
        attribute_ext.append(_SingleParentValidator(prop))

    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 m in mapper.polymorphic_iterator():
        if (m is prop.parent or not m.concrete) and m.has_property(prop.key):
            attributes.register_attribute_impl(
                m.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
            )
Example #2
0
def _register_attribute(strategy, mapper, 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 = list(util.to_list(prop.extension, default=[]))
        
    if useobject and prop.single_parent:
        attribute_ext.insert(0, _SingleParentValidator(prop))

    if prop.key in prop.parent._validators:
        attribute_ext.insert(0, 
            mapperutil.Validator(prop.key, prop.parent._validators[prop.key])
        )
    
    if useobject:
        attribute_ext.append(sessionlib.UOWEventHandler(prop.key))

    
    for m in mapper.polymorphic_iterator():
        if prop is m._props.get(prop.key):
            
            attributes.register_attribute_impl(
                m.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,
                doc=prop.doc,
                **kw
                )
Example #3
0
def _register_attribute(strategy,
                        mapper,
                        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 useobject and prop.single_parent:
        attribute_ext.append(_SingleParentValidator(prop))

    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 m in mapper.polymorphic_iterator():
        if prop is m._props.get(prop.key):

            attributes.register_attribute_impl(
                m.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)