'Subclass an app-compatible class.
App-compatible means that the class has a class attribute that
provides the default app it should use, for example:
``class Foo: app = None``.
Arguments:
Class (type): The app-compatible class to subclass.
name (str): Custom name for the target class.
attribute (str): Name of the attribute holding the app,
Default is \'app\'.
reverse (str): Reverse path to this object used for pickling
purposes. For example, to get ``app.AsyncResult``,
use ``"AsyncResult"``.
keep_reduce (bool): If enabled a custom ``__reduce__``
implementation won\'t be provided.'

def subclass_with_self(self, Class, name=None, attribute=u'app', reverse=None, keep_reduce=False, **kw):

    Class = symbol_by_name(Class)
    reverse = (reverse if reverse else Class.__name__)
    def __reduce__(self):
        return (_unpickle_appattr, (reverse, self.__reduce_args__()))
    attrs = dict({attribute: self}, __module__=Class.__module__, __doc__=Class.__doc__, **kw)
    if (not keep_reduce):
        attrs[u'__reduce__'] = __reduce__
    return type(bytes_if_py2((name or Class.__name__)), (Class,), attrs)
