Data Model version 2.1.2
Acknowledgements
Diagram | Class Map | Attribute Map | Method Map | Help | License
Home | Package | Class | Attribute | Method: { prev | next }

Method: getByNavigation


    Return object or element given a navigation sequence, or None if none found
        
    Intended to provide fast, one-function-call access to
    long range navigation, mainly for UML-embedded code.
    NB there is no error checking on the input.
    The function may fail without proper warning for incorrect input.
    Also the function bypasses the API on get commands, so that load is
    not triggered on MemopsRoot->TopObject links or partially filled
    interpackage crosslinks
    Programmer beware!

    Navigation starts at self and follows the navigation sequence,
    which consists of either string tags, or (tag,key) tuples.
    - For a string tag the function gets the corresponding element.
    Except at the end of the navigation sequence, this assumes that
    the element has hicard==1, and is a link or complex data type attribute.
    If the result evaluates false, a getattr is done instead.
    This may trigger loading and follow derived links.
    - For a (tag,key) tuple this assumes that the tag is the name of a
    child link, and gets the child with the given key.
    If no children are found and the object has an attribute isLoaded==False,
    object.load() is tried.
    - If at any stage in the lookup no object is found, None is returned
        

guid: temporary_memops.Implementation.MemopsObject.getByNavigation
OpType: otherQuery
OpSubType: None
isQuery: True
isAbstract: False
Scope: instance_level
Code:
isa = isinstance

result = self

for xx in navigation:
  dd = result.__dict__
  if isa(xx,str):
    # xx is a role name - get the link
    result = dd.get(xx) or getattr(result,xx)
  
  else:
    # xx must be a (childlink,key) tuple.
    tag,key = xx
    dd2 = dd[tag]
    if not dd2 and dd.get('isLoaded') == False:
      # we might need to load this
      try:
        result.load()
      except AttributeError:
        pass
    # Now get the child
    result = dd2.get(key)
  
  if result is None:
    break
else:

  # freeze internal representations
  if isa(result, list):
    result = tuple(result)
  elif isa(result, set):
    result = frozenset(result)
  elif isa(result, dict):
    result = frozenset(result.values())
  Data Model Version 2.1.2
Go to Top  
  Autogenerated by  PyApiDocGen  revision 1.3   on  Fri Mar 28 11:17:54 2014    from data model package  memops.api.Implementation.MemopsObject   revision ?  
  Work done by the CCPN team.
www.ccpn.ac.uk