django_socio_grpc.protobuf.generators_old_way
Module Contents
Classes
Data
API
- django_socio_grpc.protobuf.generators_old_way.MAX_SORT_NUMBER
99
- class django_socio_grpc.protobuf.generators_old_way.ModelProtoGeneratorOldWay(project_name, app_name, model_name=None, existing_proto_path=None)
Initialization
- type_mapping
None
- check_if_existing_proto_file(existing_proto_path)
This method is here only to help mocking test because os.path.exists is call multiple time
- parse_existing_proto_file(existing_proto_path)
- find_existing_number_for_field(grpc_message_name, field_name)
Find if the field for this grpc message was already existing and return its number
- order_message_by_existing_number(grpc_message_name, grpc_message_fields_name)
- get_proto()
- _generate_service(model)
- construct_method_message(message_info, model)
transform a message_info of type {is_stream:
, message: } to a rpc parameter or return value. return value example: “stream MyModelRetrieveRequest”
- _generate_messages(model)
Take a model and smartly decide why messages and which field for each message to write in the protobuf file. It use the model._meta.grpc_messages if exist or use the default configurations
- _generate_one_message(model, grpc_message_name, grpc_message_fields_name)
- get_proto_type_and_field_name(model, field_name)
Return a proto_type and a field_name to use in the proto file from a field_name and a model.
this method is the magic method that tranform custom attribute like __repeated-link– to correct proto buff file
- get_custom_item_type_and_name(field_name)
Get the Message name we want to inject to an other message to make nested serializer, repeated serializer or just custom message field_name should look like: custom[proto_type][proto_field_name] and the method will return proto_type, proto_field_name