code: def _object_getattr(obj, field):
    '''Attribute getter for the objects to operate on.
    This function can be overridden in classes or instances of Query, Filter, and
    Order. Thus, a custom function to extract values to attributes can be
    specified, and the system can remain agnostic to the client's data model,
    without loosing query power.
    For example, the default implementation works with attributes and items::
      def _object_getattr(obj, field):
        if hasattr(obj, field):
          value = getattr(obj, field)
        elif field in obj:
          value = obj[field]
        return value
    Or consider a more complex, application-specific structure::
      def _object_getattr(version, field):
        if field in ['key', 'committed', 'created', 'hash']:
          return getattr(version, field)
        else:
          return version.attributes[field]['value']
    '''
    value = None
    if hasattr(obj, field):
      value = getattr(obj, field)
    elif field in obj:
      value = obj[field]
    return value