Module Import alias ImportFrom alias ImportFrom alias ImportFrom alias alias alias alias alias ImportFrom alias Assign NameStore Call AttributeLoad NameLoad attr NameLoad Expr Str Assign NameStore Dict Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr FunctionDef arguments args NameParam defaults body Expr Str TryExcept body Assign NameStore Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Call AttributeLoad Str attr NameLoad Return NameLoad handlers ExceptHandler type NameLoad body Expr Call AttributeLoad NameLoad attr Call AttributeLoad Str attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str If CompareIs Call NameLoad NameLoad NameLoad body Assign NameStore BinOpAdd Str Call NameLoad Call AttributeLoad NameLoad attr Assign NameStore BinOpAdd Str Call AttributeLoad NameLoad attr For NameStore AttributeLoad AttributeLoad NameLoad attr attr body If CompareNotEq Call AttributeLoad AttributeLoad NameLoad attr attr Str body Continue If BoolOpOr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad body Break orelse Raise Call NameLoad Call AttributeLoad Str attr NameLoad Expr Call NameLoad NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults NameLoad body Expr Str ImportFrom alias Assign NameStore IfExp NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr Str NameLoad Assign NameStore ListLoad If AttributeLoad AttributeLoad NameLoad attr attr body ImportFrom alias identifier Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr If NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Dict Str Str Str Str Str Call AttributeLoad NameLoad attr BoolOpOr Call AttributeLoad NameLoad attr Str ListLoad BoolOpOr Call AttributeLoad NameLoad attr Str ListLoad BoolOpOr Call AttributeLoad NameLoad attr Str ListLoad BoolOpOr Call AttributeLoad NameLoad attr Str ListLoad If CompareIn Str NameLoad body Assign SubscriptStore NameLoad Index Str Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Str Dict For TupleStore NameStore NameStore Call AttributeLoad NameLoad attr body If CompareIn NameLoad NameLoad body Continue Assign NameStore Call AttributeLoad NameLoad attr Str If CompareIs NameLoad NameLoad body Continue Assign NameStore Call AttributeLoad NameLoad attr Assign SubscriptStore NameLoad Index Str Call NameLoad Call AttributeLoad NameLoad attr Str For NameStore TupleLoad Str Str body Assign NameStore Call AttributeLoad NameLoad attr NameLoad If Call NameLoad NameLoad body Assign SubscriptStore NameLoad Index NameLoad Call NameLoad NameLoad Assign NameStore Call AttributeLoad BoolOpOr Call AttributeLoad NameLoad attr Str Str Str attr If CompareNotIn NameLoad NameLoad body Raise Call NameLoad Call AttributeLoad Str attr NameLoad Assign NameStore SubscriptLoad NameLoad Index NameLoad If CompareIs NameLoad AttributeLoad NameLoad attr body Expr Call NameLoad NameLoad SubscriptLoad NameLoad Index Str NameLoad If CompareIs NameLoad AttributeLoad NameLoad attr body Assign NameStore Str Assign SubscriptStore NameLoad Index NameLoad SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index NameLoad If CompareIs NameLoad AttributeLoad NameLoad attr body Assign NameStore Str Assign SubscriptStore NameLoad Index NameLoad SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index NameLoad Assign SubscriptStore NameLoad Index NameLoad Call NameLoad NameLoad Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call NameLoad NameLoad Call NameLoad NameLoad NameLoad Expr Call NameLoad NameLoad NameLoad NameLoad Expr Call NameLoad NameLoad NameLoad NameLoad Return TupleLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad If UnaryOpNot NameLoad body Raise Call NameLoad Call AttributeLoad Str attr NameLoad If CompareIsNot NameLoad NameLoad body Return TupleLoad NameLoad Call AttributeLoad NameLoad attr Str NameLoad Expr Call AttributeLoad NameLoad attr Call AttributeLoad Str attr NameLoad Return Call NameLoad NameLoad keyword NameLoad keyword NameLoad keyword NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad TryExcept body Return Call NameLoad NameLoad NameLoad NameLoad handlers ExceptHandler type NameLoad name NameStore body Raise Call NameLoad Call AttributeLoad Str attr NameLoad Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad Assign NameStore Call AttributeLoad NameLoad attr Str Dict Assign NameStore Dict Str NameLoad For TupleStore NameStore NameStore Call AttributeLoad NameLoad attr body Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr Str Assign NameStore SubscriptLoad SubscriptLoad NameLoad Index NameLoad Index NameLoad If UnaryOpNot Call NameLoad NameLoad NameLoad body Assign NameStore ListLoad NameLoad For NameStore NameLoad body Assign NameStore Call NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr Str Dict For TupleStore NameStore NameStore Call AttributeLoad NameLoad attr body If UnaryOpNot NameLoad body Continue Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Str If NameLoad body Assign NameStore ListComp Call NameLoad NameLoad comprehension NameStore NameLoad Assign NameStore Dict Str Str NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad NameLoad If NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Str Dict Assign NameStore CompareEq Call AttributeLoad NameLoad attr Str Str Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Str If UnaryOpNot BoolOpAnd NameLoad NameLoad NameLoad body Continue Assign NameStore ListComp Call NameLoad NameLoad comprehension NameStore NameLoad Assign NameStore Dict Str Str Call AttributeLoad NameLoad attr NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad NameLoad decorator_list
N/A N/A logging nefertari engine inflection pluralize utils resolve_to_callable is_callable_tag resource_schema generate_model_name get_events_map N/A registry N/A log N/A N/A logging getLogger __name__ N/A 
Map of RAML types names to nefertari.engine fields.

 N/A type_fields N/A string float integer boolean datetime file relationship dict foreign_key big_integer date choice interval decimal pickle small_integer text time unicode unicode_text id_field list N/A engine StringField N/A engine FloatField N/A engine IntegerField N/A engine BooleanField N/A engine DateTimeField N/A engine BinaryField N/A engine Relationship N/A engine DictField N/A engine ForeignKeyField N/A engine BigIntegerField N/A engine DateField N/A engine ChoiceField N/A engine IntervalField N/A engine DecimalField N/A engine PickleField N/A engine SmallIntegerField N/A engine TextField N/A engine TimeField N/A engine UnicodeField N/A engine UnicodeTextField N/A engine IdField N/A engine ListField get_existing_model N/A N/A model_name N/A N/A N/A  Try to find existing model class named `model_name`.

    :param model_name: String name of the model class.
     N/A N/A N/A model_cls N/A N/A engine get_document_cls model_name N/A N/A N/A log debug N/A N/A Model `{}` already exists. Using existing one format model_name N/A model_cls N/A N/A N/A ValueError N/A N/A N/A N/A log debug N/A N/A Model `{}` does not exist format model_name N/A prepare_relationship N/A N/A config model_name raml_resource N/A N/A N/A  Create referenced model if it doesn't exist.

    When preparing a relationship, we check to see if the model that will be
    referenced already exists. If not, it is created so that it will be possible
    to use it in a relationship. Thus the first usage of this model in RAML file
    must provide its schema in POST method resource body schema.

    :param model_name: Name of model which should be generated.
    :param raml_resource: Instance of ramlfications.raml.ResourceNode for
        which :model_name: will be defined.
     N/A N/A N/A get_existing_model model_name None N/A N/A plural_route N/A / N/A pluralize N/A N/A model_name lower N/A route N/A / N/A N/A model_name lower N/A res N/A N/A raml_resource root resources N/A N/A N/A N/A N/A N/A res method upper POST N/A N/A N/A N/A N/A N/A N/A res path endswith plural_route N/A N/A N/A res path endswith route N/A N/A N/A N/A N/A ValueError N/A N/A Model `{}` used in relationship is not defined format model_name N/A N/A setup_data_model config res model_name N/A generate_model_cls N/A N/A config schema model_name raml_resource es_based N/A True N/A N/A  Generate model class.

    Engine DB field types are determined using `type_fields` and only those
    types may be used.

    :param schema: Model schema dict parsed from RAML.
    :param model_name: String that is used as new model's name.
    :param raml_resource: Instance of ramlfications.raml.ResourceNode.
    :param es_based: Boolean indicating if generated model should be a
        subclass of Elasticsearch-based document class or not.
        It True, ESBaseDocument is used; BaseDocument is used otherwise.
        Defaults to True.
     nefertari.authentication.models AuthModelMethodsMixin N/A base_cls N/A es_based N/A engine ESBaseDocument N/A engine BaseDocument N/A model_name N/A str model_name N/A metaclass N/A type base_cls N/A auth_model N/A N/A schema get _auth_model False N/A bases N/A N/A N/A N/A config registry database_acls N/A nefertari_guards engine guards_engine N/A N/A N/A bases append N/A guards_engine DocumentACLMixin N/A auth_model N/A N/A N/A N/A bases append AuthModelMethodsMixin N/A N/A N/A bases append base_cls N/A attrs N/A __tablename__ _public_fields _auth_fields _hidden_fields _nested_relationships N/A N/A model_name lower N/A N/A N/A schema get _public_fields N/A N/A N/A N/A schema get _auth_fields N/A N/A N/A N/A schema get _hidden_fields N/A N/A N/A N/A schema get _nested_relationships N/A N/A N/A _nesting_depth schema N/A N/A N/A attrs N/A _nesting_depth N/A N/A schema get _nesting_depth N/A properties N/A N/A schema get properties N/A N/A N/A field_name props N/A N/A properties items N/A N/A N/A field_name attrs N/A N/A N/A db_settings N/A N/A props get _db_settings N/A N/A db_settings None N/A N/A N/A field_kwargs N/A N/A db_settings copy N/A N/A field_kwargs N/A required N/A bool N/A N/A field_kwargs get required N/A default_attr_key N/A default onupdate N/A N/A value N/A N/A field_kwargs get default_attr_key N/A N/A is_callable_tag value N/A N/A N/A field_kwargs N/A default_attr_key N/A resolve_to_callable value N/A type_name N/A N/A N/A N/A N/A field_kwargs pop type string string lower N/A N/A type_name type_fields N/A N/A N/A ValueError N/A N/A Unknown type: {} format type_name N/A field_cls N/A type_fields N/A type_name N/A N/A field_cls N/A engine Relationship N/A N/A N/A prepare_relationship config N/A field_kwargs N/A document raml_resource N/A N/A field_cls N/A engine ForeignKeyField N/A N/A key ref_column_type N/A N/A field_kwargs N/A key N/A type_fields N/A N/A field_kwargs N/A key N/A N/A field_cls N/A engine ListField N/A N/A key item_type N/A N/A field_kwargs N/A key N/A type_fields N/A N/A field_kwargs N/A key N/A N/A attrs N/A field_name N/A field_cls field_kwargs N/A N/A N/A attrs update N/A N/A registry mget model_name N/A model_cls N/A metaclass model_name N/A tuple bases attrs N/A N/A setup_model_event_subscribers config model_cls schema N/A N/A setup_fields_processors config model_cls schema N/A N/A model_cls auth_model N/A setup_data_model N/A N/A config raml_resource model_name N/A N/A N/A  Setup storage/data model and return generated model class.

    Process follows these steps:
      * Resource schema is found and restructured by `resource_schema`.
      * Model class is generated from properties dict using util function
        `generate_model_cls`.

    :param raml_resource: Instance of ramlfications.raml.ResourceNode.
    :param model_name: String representing model name.
     N/A model_cls N/A get_existing_model model_name N/A schema N/A resource_schema raml_resource N/A N/A schema N/A N/A N/A Exception N/A N/A Missing schema for model `{}` format model_name N/A N/A model_cls None N/A N/A N/A model_cls N/A N/A schema get _auth_model False N/A N/A N/A log info N/A N/A Generating model class `{}` format model_name N/A N/A generate_model_cls config schema schema model_name model_name raml_resource raml_resource N/A handle_model_generation N/A N/A config raml_resource route_name N/A N/A N/A  Generates model name and runs `setup_data_model` to get
    or generate actual model class.

    :param raml_resource: Instance of ramlfications.raml.ResourceNode.
    :param route_name: String name of the resource.
     N/A model_name N/A generate_model_name route_name N/A N/A N/A N/A setup_data_model config raml_resource model_name N/A N/A N/A ValueError N/A ex N/A N/A N/A ValueError N/A N/A {}: {} format model_name N/A str ex N/A setup_model_event_subscribers N/A N/A config model_cls schema N/A N/A N/A  Set up model event subscribers.

    :param config: Pyramid Configurator instance.
    :param model_cls: Model class for which handlers should be connected.
    :param schema: Dict of model JSON schema.
     N/A events_map N/A get_events_map N/A model_events N/A N/A schema get _event_handlers N/A N/A event_kwargs N/A model model_cls N/A N/A event_tag subscribers N/A N/A model_events items N/A N/A N/A type_ action N/A N/A event_tag split _ N/A event_objects N/A N/A events_map N/A type_ N/A action N/A N/A N/A isinstance event_objects list N/A N/A event_objects N/A event_objects N/A sub_name subscribers N/A N/A sub_func N/A resolve_to_callable sub_name N/A N/A N/A config subscribe_to_events sub_func event_objects event_kwargs N/A setup_fields_processors N/A N/A config model_cls schema N/A N/A N/A  Set up model fields' processors.

    :param config: Pyramid Configurator instance.
    :param model_cls: Model class for field of which processors should be
        set up.
    :param schema: Dict of model JSON schema.
     N/A properties N/A N/A schema get properties N/A N/A N/A field_name props N/A N/A properties items N/A N/A N/A props N/A N/A N/A processors N/A N/A props get _processors N/A backref_processors N/A N/A props get _backref_processors N/A processors N/A N/A processors N/A N/A resolve_to_callable val N/A val processors N/A setup_kwargs N/A model field model_cls field_name N/A N/A N/A config add_field_processors processors setup_kwargs N/A backref_processors N/A N/A db_settings N/A N/A props get _db_settings N/A N/A is_relationship N/A N/A N/A db_settings get type relationship N/A document N/A N/A db_settings get document N/A backref_name N/A N/A db_settings get backref_name N/A N/A N/A is_relationship document backref_name N/A N/A N/A backref_processors N/A N/A resolve_to_callable val N/A val backref_processors N/A setup_kwargs N/A model field N/A N/A engine get_document_cls document backref_name N/A N/A N/A config add_field_processors backref_processors setup_kwargs N/A