def _fix_up_fields(cls):
        """Add names to all of the Resource fields.

        This method will get called on class declaration because of
        Resource's metaclass.  The functionality is based on Google's NDB
        implementation.

        `Endpoint` does something similar for `arguments`.
        """
        cls._fields = {}
        if cls.__module__ == __name__ and cls.__name__ != 'DebugResource':
            return
        for name in set(dir(cls)):
            attr = getattr(cls, name, None)
            if isinstance(attr, BaseField):
                if name.startswith('_'):
                    raise TypeError("Resource field %s cannot begin with an "
                            "underscore.  Underscore attributes are reserved "
                            "for instance variables that aren't intended to "
                            "propagate out to the HTTP caller." % name)
                attr._fix_up(cls, name)
                cls._fields[attr.name] = attr
        if cls._default_fields is None:
            cls._default_fields = tuple(cls._fields.keys())