예제 #1
0
def get_schemas(model_or_obj, marker=None):
    model_or_obj = removeSecurityProxy(model_or_obj)

    for schema in get_direct_interfaces(model_or_obj):
        yield schema

    model = model_or_obj if isinstance(model_or_obj, type) else type(model_or_obj)

    for schema in getSiteManager().adapters._adapters[1].get(implementedBy(model), []):
        yield schema

    if model_implements_marker(model_or_obj, marker):
        yield marker
def assert_direct_interfaces(cls, interfaces, instance=NONE):
    if instance is NONE:
        instance = cls()
    for i in (cls, instance):
        direct_interfaces = get_direct_interfaces(i)
        assert interfaces == direct_interfaces, "%s should have no direct interfaces" % i
        if len(interfaces) <= 1:
            direct_interface = get_direct_interface(i)
            assert (interfaces[0] if interfaces else None) == direct_interface,\
                    "%s should not have a direct interface" % i
        else:
            with assert_raises(Exception) as cm:
                get_direct_interface(i)
            assert cm.exception.args == ("Object implements more than 1 interface", )
def assert_direct_interfaces(cls, interfaces, instance=NONE):
    if instance is NONE:
        instance = cls()
    for i in (cls, instance):
        direct_interfaces = get_direct_interfaces(i)
        assert interfaces == direct_interfaces, "%s should have no direct interfaces" % i
        if len(interfaces) <= 1:
            direct_interface = get_direct_interface(i)
            assert (interfaces[0] if interfaces else None) == direct_interface,\
                    "%s should not have a direct interface" % i
        else:
            with assert_raises(Exception) as cm:
                get_direct_interface(i)
            assert cm.exception.args == (
                "Object implements more than 1 interface", )
예제 #4
0
 def class_implemented_interfaces(cls):
     return get_direct_interfaces(cls)
예제 #5
0
 def class_implemented_interfaces(cls):
     return get_direct_interfaces(cls)