def servicemethod(*args, **kwargs):
    """ The Service method decorator.

        Decorate a function or method to expose it remotely
        via RPC (or other mechanism.)

        Arguments:

            name (optional):
                The name of this method as seen remotely.

            store (required if not decorating a bound Store method):
                A reference to the Store this method operates on.

                This is required if the method is a regular function,
                a staticmethod or otherwise defined outside a Store instance.
                (ie doesn't take a 'self' argument)

            store_arg (optional):
                Specifies whether this method should be passed the Store instance
                as the first argument (default is True so that servicemethods bound to
                a store instance can get a proper 'self' reference.)

            request_arg (optional):
                Specifies whether this method should be passed a reference to the current
                Request object.  (Default is True)

            If both store_arg and request_arg are True, the the store will be passed first,
            then the request (to appease bound store methods that need a 'self' as the first arg)

            If only one is True then that one will be passed first.  This is useful for using
            standard Django view functions as servicemethods since they require the 'request'
            as the first argument.
    """
    # Default options
    options = {'name': None, 'store': None, 'request_arg': True, 'store_arg': True}

    # Figure out if we were called with arguments
    # If we were called with args, ie:
    # @servicemethod(name='Foo')
    # Then the only argument here will be the pre-decorated function/method object.
    method = ( (len(args) == 1) and callable(args[0]) ) and args[0] or None

    if method is None:
        # We were called with args, (or  @servicemethod() )
        # so figure out what they were ...

        # The method name should be either the first non-kwarg
        # or the kwarg 'name'
        # Example: @servicemethod('my_method', ...) or @servicemethod(name='my_method')
        options.update({
            'name': bool(args) and args[0] or kwargs.pop('name', None),
            'store': (2 >= len(args)) and args[1] or kwargs.pop('store', None),
            'request_arg': kwargs.pop('request_arg', True),
            'store_arg': kwargs.pop('store_arg', True),
        })
    else:
        options['name'] = method.__name__
        method.__servicemethod__ = options

    def method_with_args_wrapper(method):
        """ Wrapper for a method decorated with decorator arguments
        """
        if options['name'] is None:
            options['name'] = method.__name__
        method.__servicemethod__ = options

        if options['store'] is not None:
            options['store'].service.add_method(method)

        return method

    return method or method_with_args_wrapper
dataset/ETHPy150Open klipstein/dojango/dojango/data/modelstore/services.py/servicemethod/swapped operands of `>=`