MCPcopy Index your code
hub / github.com/MongoEngine/mongoengine / __init__

Method __init__

mongoengine/fields.py:1460–1477  ·  view source on GitHub ↗
(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

1458 """
1459
1460 def __init__(self, *args, **kwargs):
1461 choices = kwargs.pop("choices", None)
1462 super().__init__(*args, **kwargs)
1463 self.choices = []
1464 # Keep the choices as a list of allowed Document class names
1465 if choices:
1466 for choice in choices:
1467 if isinstance(choice, str):
1468 self.choices.append(choice)
1469 elif isinstance(choice, type) and issubclass(choice, Document):
1470 self.choices.append(choice._class_name)
1471 else:
1472 # XXX ValidationError raised outside of the "validate"
1473 # method.
1474 self.error(
1475 "Invalid choices provided: must be a list of"
1476 "Document subclasses and/or str"
1477 )
1478
1479 def _validate_choices(self, value):
1480 if isinstance(value, dict):

Callers

nothing calls this directly

Calls 3

popMethod · 0.80
errorMethod · 0.80
__init__Method · 0.45

Tested by

no test coverage detected