def get_fields_and_servicemethods(bases, attrs, include_bases=True):
    """ This function was pilfered (and slightly modified) from django/forms/forms.py
        See the original function for doc and comments.
    """
    fields = [ (field_name, attrs.pop(field_name)) for \
        field_name, obj in attrs.items() if isinstance(obj, StoreField)]

    # Get the method name directly from the __servicemethod__ dict
    # as set by the decorator
    methods = [ (method.__servicemethod__['name'], method) for \
        method in attrs.values() if hasattr(method, '__servicemethod__') ]

    if include_bases:
        for base in bases[::-1]:

            # Grab the fields and servicemethods from the base classes
            try:
                fields = base.fields.items() + fields
            except AttributeError:
                pass

            try:
                methods = base.servicemethods.items() + methods
            except __HOLE__:
                pass

    return SortedDict(fields), SortedDict(methods)
dataset/ETHPy150Open klipstein/dojango/dojango/data/modelstore/utils.py/get_fields_and_servicemethods