def _to_tuple(note_dict): """ Return a ``namedtuple`` representation of the supplied ``note_dict``. :param dict note_dict: ``dict`` representation of a :class:`spidernotes.models.Note` """ is_deleted = bool(note_dict.get('isDeleted')) return _NoteTuple( id=get_param(note_dict, 'id'), body=get_param(note_dict, 'body') if not is_deleted else '', url=get_param(note_dict, 'url') if not is_deleted else '', is_deleted=is_deleted, created=from_timestamp(get_param(note_dict, 'created')), modified=from_timestamp(get_param(note_dict, 'modified')))
def get_user(self): """ Return the current :class:`google.appengine.api.users.User` or ``None``. """ user = None auth_id = get_param(self.request.headers, _AUTH_ID_HEADER_KEY) if auth_id: try: user = User.get_by_auth_id(auth_id) except BadRequestError: _log.exception('Error getting user by auth_id: {}'.format( auth_id)) return user