@staticmethod<EOL><INDENT>def _parse_from_ref(cls, pairs=None, flat=None,<EOL>reference=None, serialized=None, urlsafe=None,<EOL>app=None, namespace=None, parent=None):<DEDENT>
if cls is not Key:<EOL><INDENT>raise TypeError('<STR_LIT>'<EOL>'<STR_LIT>' % cls)<EOL><DEDENT>if (bool(pairs) + bool(flat) + bool(reference) + bool(serialized) +<EOL>bool(urlsafe) + bool(parent)) != <NUM_LIT:1>:<EOL><INDENT>raise TypeError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>if urlsafe:<EOL><INDENT>serialized = _DecodeUrlSafe(urlsafe)<EOL><DEDENT>if serialized:<EOL><INDENT>reference = _ReferenceFromSerialized(serialized)<EOL><DEDENT>if reference:<EOL><INDENT>reference = _ReferenceFromReference(reference)<EOL><DEDENT>pairs = []<EOL>elem = None<EOL>path = reference.path()<EOL>for elem in path.element_list():<EOL><INDENT>kind = elem.type()<EOL>if elem.has_id():<EOL><INDENT>id_or_name = elem.id()<EOL><DEDENT>else:<EOL><INDENT>id_or_name = elem.name()<EOL><DEDENT>if not id_or_name:<EOL><INDENT>id_or_name = None<EOL><DEDENT>tup = (kind, id_or_name)<EOL>pairs.append(tup)<EOL><DEDENT>if elem is None:<EOL><INDENT>raise RuntimeError('<STR_LIT>'<EOL>% (urlsafe, serialized, str(reference)))<EOL><DEDENT>ref_app = reference.app()<EOL>if app is not None:<EOL><INDENT>if app != ref_app:<EOL><INDENT>raise RuntimeError('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(ref_app, app))<EOL><DEDENT><DEDENT>ref_namespace = reference.name_space()<EOL>if namespace is not None:<EOL><INDENT>if namespace != ref_namespace:<EOL><INDENT>raise RuntimeError('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(ref_namespace, namespace))<EOL><DEDENT><DEDENT>return (reference, tuple(pairs), ref_app, ref_namespace)<EOL>
Construct a Reference; the signature is the same as for Key.