This is called to create a new instance of this class when we need new Nodes (or subclasses) in the internal code in this class. Normally, it just shadows __init__(). However, subclasses with an __init__ signature that is not an extension of Node.__init__ might need
(cls, children=None, connector=None, negated=False)
| 266 | # We need this because of django.db.models.query_utils.Q. Q. __init__() is |
| 267 | # problematic, but it is a natural Node subclass in all other respects. |
| 268 | def _new_instance(cls, children=None, connector=None, negated=False): |
| 269 | """ |
| 270 | This is called to create a new instance of this class when we need new |
| 271 | Nodes (or subclasses) in the internal code in this class. Normally, it |
| 272 | just shadows __init__(). However, subclasses with an __init__ signature |
| 273 | that is not an extension of Node.__init__ might need to implement this |
| 274 | method to allow a Node to create a new instance of them (if they have |
| 275 | any extra setting up to do). |
| 276 | """ |
| 277 | obj = SearchNode(children, connector, negated) |
| 278 | obj.__class__ = cls |
| 279 | return obj |
| 280 | |
| 281 | _new_instance = classmethod(_new_instance) |
| 282 |
no test coverage detected