'Finds components of a table
@param table: the table or table name
@param names: a list of components names to limit the search to,
None for all available components'

@classmethod
def get_components(cls, table, names=None):

    components = current.model.components
    load = cls.table
    if (type(table) is Table):
        tablename = table._tablename
    else:
        tablename = table
        table = load(tablename)
        if (table is None):
            return None
    single = False
    if isinstance(names, str):
        single = True
        names = set([names])
    elif (names is not None):
        names = set(names)
    hooks = {}
    get_hooks = cls.__get_hooks
    direct_components = components.get(tablename)
    if direct_components:
        names = get_hooks(hooks, direct_components, names=names)
    supertables = None
    if ((names is None) or names):
        supertables = cls.get_config(tablename, 'super_entity')
        if supertables:
            if (not isinstance(supertables, (list, tuple))):
                supertables = [supertables]
            for s in supertables:
                if isinstance(s, str):
                    s = load(s)
                if (s is None):
                    continue
                super_components = components.get(s._tablename)
                if super_components:
                    names = get_hooks(hooks, super_components, names=names, supertable=s)
    dynamic_components = cls.get_config(tablename, 'dynamic_components')
    if dynamic_components:
        if ((names is None) or names):
            cls.add_dynamic_components(tablename, exclude=hooks)
            direct_components = components.get(tablename)
            if direct_components:
                names = get_hooks(hooks, direct_components, names=names)
        if (supertables and ((names is None) or names)):
            for s in supertables:
                if isinstance(s, str):
                    s = load(s)
                if (s is None):
                    continue
                cls.add_dynamic_components(s._tablename, exclude=hooks)
                super_components = components.get(s._tablename)
                if super_components:
                    names = get_hooks(hooks, super_components, names=names, supertable=s)
    components = Storage()
    for alias in hooks:
        hook = hooks[alias]
        tn = hook.tablename
        lt = hook.linktable
        ctable = load(tn)
        if (ctable is None):
            continue
        if lt:
            ltable = load(lt)
            if (ltable is None):
                continue
        else:
            ltable = None
        (prefix, name) = tn.split('_', 1)
        component = Storage(defaults=hook.defaults, multiple=hook.multiple, tablename=tn, table=ctable, prefix=prefix, name=name, alias=alias)
        if (hook.supertable is not None):
            joinby = hook.supertable._id.name
        else:
            joinby = hook.fkey
        if (hook.pkey is None):
            if (hook.supertable is not None):
                component.pkey = joinby
            else:
                component.pkey = table._id.name
        else:
            component.pkey = hook.pkey
        if (ltable is not None):
            if hook.actuate:
                component.actuate = hook.actuate
            else:
                component.actuate = 'link'
            component.linktable = ltable
            if (hook.fkey is None):
                component.fkey = ctable._id.name
            else:
                component.fkey = hook.fkey
            component.lkey = hook.lkey
            component.rkey = hook.rkey
            component.autocomplete = hook.autocomplete
            component.autodelete = hook.autodelete
        else:
            component.linktable = None
            component.fkey = hook.fkey
            component.lkey = component.rkey = None
            component.actuate = None
            component.autocomplete = None
            component.autodelete = None
        if (hook.filterby is not None):
            component.filterby = hook.filterby
        components[alias] = component
    return components
