def __init__(self, title=None, snode=None, _obj=None): if title: snode = library.get_schema_node(title) if not snode: snode = library.get_schema_node(title, with_commentary=True) if not snode: raise InputError(u"Can not resolve name: {}".format(title)) self.snode = snode self.versionState = VersionState(snode.index.title) self.d = self.versionState.content_node(snode) elif snode: self.snode = snode self.versionState = VersionState(snode.index.title) self.d = self.versionState.content_node(snode) elif _obj: self.d = _obj
def __init__(self, title=None, snode=None, _obj=None, meta=False, hint=None): """ :param title: :param snode: :param _obj: :param meta: If true, returns only the overview information, and not the detailed counts :param hint: hint - a list of (lang, key) tuples of pieces of VersionState to return :return: """ if title: snode = library.get_schema_node(title) if not snode: snode = library.get_schema_node(title) if not snode: raise InputError(u"Can not resolve name: {}".format(title)) if snode.is_default(): snode = snode.parent if snode: proj = None if meta: if snode.parent: raise Exception( "StateNode.meta() only supported for Index roots. Called with {} / {}" .format(title, snode.primary_title("en"))) proj = self.meta_proj if hint: hint_proj = {} base = [VersionState.content_attr] + snode.version_address() for l, k in hint: hint_proj[".".join(base + [self.lang_map[l]] + [k])] = 1 if proj: proj.update(hint_proj) else: proj = hint_proj self.snode = snode self.versionState = VersionState(snode.index.title, proj=proj) self.d = self.versionState.content_node(snode) elif _obj: self.d = _obj
def __init__(self, title=None, snode=None, _obj=None, meta=False, hint=None): """ :param title: :param snode: :param _obj: :param meta: If true, returns only the overview information, and not the detailed counts :param hint: hint - a list of (lang, key) tuples of pieces of VersionState to return :return: """ if title: snode = library.get_schema_node(title) if not snode: snode = library.get_schema_node(title, with_commentary=True) if not snode: raise InputError(u"Can not resolve name: {}".format(title)) if snode.is_default(): snode = snode.parent if snode: proj = None if meta: if snode.parent: raise Exception( "StateNode.meta() only supported for Index roots. Called with {} / {}".format( title, snode.primary_title("en") ) ) proj = self.meta_proj if hint: hint_proj = {} base = [VersionState.content_attr] + snode.version_address() for l, k in hint: hint_proj[".".join(base + [self.lang_map[l]] + [k])] = 1 if proj: proj.update(hint_proj) else: proj = hint_proj self.snode = snode self.versionState = VersionState(snode.index.title, proj=proj) self.d = self.versionState.content_node(snode) elif _obj: self.d = _obj