'Helper function that returns info about attributes and/or
non-persistent data stored on object'

def format_attributes(self, obj, attrname=None, crop=True):

    if attrname:
        db_attr = [(attrname, obj.attributes.get(attrname))]
        try:
            ndb_attr = [(attrname, object.__getattribute__(obj.ndb, attrname))]
        except Exception:
            ndb_attr = None
    else:
        db_attr = [(attr.key, attr.value) for attr in obj.db_attributes.all()]
        try:
            ndb_attr = obj.nattributes.all(return_tuples=True)
        except Exception:
            ndb_attr = None
    string = ''
    if (db_attr and db_attr[0]):
        string += '\n|wPersistent    attributes|n:'
        for (attr, value) in db_attr:
            string += self.list_attribute(crop, attr, value)
    if (ndb_attr and ndb_attr[0]):
        string += '\n|wNon-Persistent    attributes|n:'
        for (attr, value) in ndb_attr:
            string += self.list_attribute(crop, attr, value)
    return string
