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. na
(self, Class, name=None, attribute='app',
reverse=None, keep_reduce=False, **kw)
| 1254 | ) |
| 1255 | |
| 1256 | def subclass_with_self(self, Class, name=None, attribute='app', |
| 1257 | reverse=None, keep_reduce=False, **kw): |
| 1258 | """Subclass an app-compatible class. |
| 1259 | |
| 1260 | App-compatible means that the class has a class attribute that |
| 1261 | provides the default app it should use, for example: |
| 1262 | ``class Foo: app = None``. |
| 1263 | |
| 1264 | Arguments: |
| 1265 | Class (type): The app-compatible class to subclass. |
| 1266 | name (str): Custom name for the target class. |
| 1267 | attribute (str): Name of the attribute holding the app, |
| 1268 | Default is 'app'. |
| 1269 | reverse (str): Reverse path to this object used for pickling |
| 1270 | purposes. For example, to get ``app.AsyncResult``, |
| 1271 | use ``"AsyncResult"``. |
| 1272 | keep_reduce (bool): If enabled a custom ``__reduce__`` |
| 1273 | implementation won't be provided. |
| 1274 | """ |
| 1275 | Class = symbol_by_name(Class) |
| 1276 | reverse = reverse if reverse else Class.__name__ |
| 1277 | |
| 1278 | def __reduce__(self): |
| 1279 | return _unpickle_appattr, (reverse, self.__reduce_args__()) |
| 1280 | |
| 1281 | attrs = dict( |
| 1282 | {attribute: self}, |
| 1283 | __module__=Class.__module__, |
| 1284 | __doc__=Class.__doc__, |
| 1285 | **kw) |
| 1286 | if not keep_reduce: |
| 1287 | attrs['__reduce__'] = __reduce__ |
| 1288 | |
| 1289 | return type(name or Class.__name__, (Class,), attrs) |
| 1290 | |
| 1291 | def _rgetattr(self, path): |
| 1292 | return attrgetter(path)(self) |
no outgoing calls
no test coverage detected