repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
cloudendpoints/endpoints-python
endpoints/discovery_service.py
DiscoveryService.handle_discovery_request
def handle_discovery_request(self, path, request, start_response): """Returns the result of a discovery service request. This calls start_response and returns the response body. Args: path: A string containing the API path (the portion of the path after /_ah/api/). request: An ApiReque...
python
def handle_discovery_request(self, path, request, start_response): """Returns the result of a discovery service request. This calls start_response and returns the response body. Args: path: A string containing the API path (the portion of the path after /_ah/api/). request: An ApiReque...
Returns the result of a discovery service request. This calls start_response and returns the response body. Args: path: A string containing the API path (the portion of the path after /_ah/api/). request: An ApiRequest, the transformed request sent to the Discovery API. start_respons...
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/discovery_service.py#L195-L220
cloudendpoints/endpoints-python
endpoints/api_request.py
ApiRequest._process_req_body
def _process_req_body(self, body): """Process the body of the HTTP request. If the body is valid JSON, return the JSON as a dict. Else, convert the key=value format to a dict and return that. Args: body: The body of the HTTP request. """ try: return json.loads(body) except Valu...
python
def _process_req_body(self, body): """Process the body of the HTTP request. If the body is valid JSON, return the JSON as a dict. Else, convert the key=value format to a dict and return that. Args: body: The body of the HTTP request. """ try: return json.loads(body) except Valu...
Process the body of the HTTP request. If the body is valid JSON, return the JSON as a dict. Else, convert the key=value format to a dict and return that. Args: body: The body of the HTTP request.
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_request.py#L118-L130
cloudendpoints/endpoints-python
endpoints/api_request.py
ApiRequest._reconstruct_relative_url
def _reconstruct_relative_url(self, environ): """Reconstruct the relative URL of this request. This is based on the URL reconstruction code in Python PEP 333: http://www.python.org/dev/peps/pep-0333/#url-reconstruction. Rebuild the URL from the pieces available in the environment. Args: env...
python
def _reconstruct_relative_url(self, environ): """Reconstruct the relative URL of this request. This is based on the URL reconstruction code in Python PEP 333: http://www.python.org/dev/peps/pep-0333/#url-reconstruction. Rebuild the URL from the pieces available in the environment. Args: env...
Reconstruct the relative URL of this request. This is based on the URL reconstruction code in Python PEP 333: http://www.python.org/dev/peps/pep-0333/#url-reconstruction. Rebuild the URL from the pieces available in the environment. Args: environ: An environ dict for the request as defined in P...
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_request.py#L132-L149
cloudendpoints/endpoints-python
endpoints/api_request.py
ApiRequest.reconstruct_hostname
def reconstruct_hostname(self, port_override=None): """Reconstruct the hostname of a request. This is based on the URL reconstruction code in Python PEP 333: http://www.python.org/dev/peps/pep-0333/#url-reconstruction. Rebuild the hostname from the pieces available in the environment. Args: ...
python
def reconstruct_hostname(self, port_override=None): """Reconstruct the hostname of a request. This is based on the URL reconstruction code in Python PEP 333: http://www.python.org/dev/peps/pep-0333/#url-reconstruction. Rebuild the hostname from the pieces available in the environment. Args: ...
Reconstruct the hostname of a request. This is based on the URL reconstruction code in Python PEP 333: http://www.python.org/dev/peps/pep-0333/#url-reconstruction. Rebuild the hostname from the pieces available in the environment. Args: port_override: str, An override for the port on the return...
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_request.py#L151-L171
cloudendpoints/endpoints-python
endpoints/api_request.py
ApiRequest.reconstruct_full_url
def reconstruct_full_url(self, port_override=None): """Reconstruct the full URL of a request. This is based on the URL reconstruction code in Python PEP 333: http://www.python.org/dev/peps/pep-0333/#url-reconstruction. Rebuild the hostname from the pieces available in the environment. Args: ...
python
def reconstruct_full_url(self, port_override=None): """Reconstruct the full URL of a request. This is based on the URL reconstruction code in Python PEP 333: http://www.python.org/dev/peps/pep-0333/#url-reconstruction. Rebuild the hostname from the pieces available in the environment. Args: ...
Reconstruct the full URL of a request. This is based on the URL reconstruction code in Python PEP 333: http://www.python.org/dev/peps/pep-0333/#url-reconstruction. Rebuild the hostname from the pieces available in the environment. Args: port_override: str, An override for the port on the return...
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_request.py#L173-L188
cloudendpoints/endpoints-python
endpoints/openapi_generator.py
OpenApiGenerator._add_def_paths
def _add_def_paths(self, prop_dict): """Recursive method to add relative paths for any $ref objects. Args: prop_dict: The property dict to alter. Side Effects: Alters prop_dict in-place. """ for prop_key, prop_value in prop_dict.iteritems(): if prop_key == '$ref' and not 'prop_va...
python
def _add_def_paths(self, prop_dict): """Recursive method to add relative paths for any $ref objects. Args: prop_dict: The property dict to alter. Side Effects: Alters prop_dict in-place. """ for prop_key, prop_value in prop_dict.iteritems(): if prop_key == '$ref' and not 'prop_va...
Recursive method to add relative paths for any $ref objects. Args: prop_dict: The property dict to alter. Side Effects: Alters prop_dict in-place.
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/openapi_generator.py#L98-L111
cloudendpoints/endpoints-python
endpoints/openapi_generator.py
OpenApiGenerator._construct_operation_id
def _construct_operation_id(self, service_name, protorpc_method_name): """Return an operation id for a service method. Args: service_name: The name of the service. protorpc_method_name: The ProtoRPC method name. Returns: A string representing the operation id. """ # camelCase th...
python
def _construct_operation_id(self, service_name, protorpc_method_name): """Return an operation id for a service method. Args: service_name: The name of the service. protorpc_method_name: The ProtoRPC method name. Returns: A string representing the operation id. """ # camelCase th...
Return an operation id for a service method. Args: service_name: The name of the service. protorpc_method_name: The ProtoRPC method name. Returns: A string representing the operation id.
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/openapi_generator.py#L113-L128
cloudendpoints/endpoints-python
endpoints/openapi_generator.py
OpenApiGenerator.__field_to_parameter_type_and_format
def __field_to_parameter_type_and_format(self, field): """Converts the field variant type into a tuple describing the parameter. Args: field: An instance of a subclass of messages.Field. Returns: A tuple with the type and format of the field, respectively. Raises: TypeError: if the ...
python
def __field_to_parameter_type_and_format(self, field): """Converts the field variant type into a tuple describing the parameter. Args: field: An instance of a subclass of messages.Field. Returns: A tuple with the type and format of the field, respectively. Raises: TypeError: if the ...
Converts the field variant type into a tuple describing the parameter. Args: field: An instance of a subclass of messages.Field. Returns: A tuple with the type and format of the field, respectively. Raises: TypeError: if the field variant is a message variant.
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/openapi_generator.py#L211-L246
cloudendpoints/endpoints-python
endpoints/openapi_generator.py
OpenApiGenerator.__parameter_default
def __parameter_default(self, field): """Returns default value of field if it has one. Args: field: A simple field. Returns: The default value of the field, if any exists, with the exception of an enum field, which will have its value cast to a string. """ if field.default: ...
python
def __parameter_default(self, field): """Returns default value of field if it has one. Args: field: A simple field. Returns: The default value of the field, if any exists, with the exception of an enum field, which will have its value cast to a string. """ if field.default: ...
Returns default value of field if it has one. Args: field: A simple field. Returns: The default value of the field, if any exists, with the exception of an enum field, which will have its value cast to a string.
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/openapi_generator.py#L340-L354
cloudendpoints/endpoints-python
endpoints/openapi_generator.py
OpenApiGenerator.__non_body_parameter_descriptor
def __non_body_parameter_descriptor(self, param): """Creates descriptor for a parameter. Args: param: The parameter to be described. Returns: Dictionary containing a descriptor for the parameter. """ descriptor = {} descriptor['name'] = param.name param_type, param_format = s...
python
def __non_body_parameter_descriptor(self, param): """Creates descriptor for a parameter. Args: param: The parameter to be described. Returns: Dictionary containing a descriptor for the parameter. """ descriptor = {} descriptor['name'] = param.name param_type, param_format = s...
Creates descriptor for a parameter. Args: param: The parameter to be described. Returns: Dictionary containing a descriptor for the parameter.
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/openapi_generator.py#L383-L423
cloudendpoints/endpoints-python
endpoints/openapi_generator.py
OpenApiGenerator.__add_parameter
def __add_parameter(self, param, path_parameters, params): """Adds all parameters in a field to a method parameters descriptor. Simple fields will only have one parameter, but a message field 'x' that corresponds to a message class with fields 'y' and 'z' will result in parameters 'x.y' and 'x.z', for ...
python
def __add_parameter(self, param, path_parameters, params): """Adds all parameters in a field to a method parameters descriptor. Simple fields will only have one parameter, but a message field 'x' that corresponds to a message class with fields 'y' and 'z' will result in parameters 'x.y' and 'x.z', for ...
Adds all parameters in a field to a method parameters descriptor. Simple fields will only have one parameter, but a message field 'x' that corresponds to a message class with fields 'y' and 'z' will result in parameters 'x.y' and 'x.z', for example. The mapping from field to parameters is mostly handle...
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/openapi_generator.py#L448-L482
cloudendpoints/endpoints-python
endpoints/openapi_generator.py
OpenApiGenerator.__params_descriptor_without_container
def __params_descriptor_without_container(self, message_type, request_kind, method_id, path): """Describe parameters of a method which does not use a ResourceContainer. Makes sure that the path parameters are included in the message definition and adds any requir...
python
def __params_descriptor_without_container(self, message_type, request_kind, method_id, path): """Describe parameters of a method which does not use a ResourceContainer. Makes sure that the path parameters are included in the message definition and adds any requir...
Describe parameters of a method which does not use a ResourceContainer. Makes sure that the path parameters are included in the message definition and adds any required fields and URL query parameters. This method is to preserve backwards compatibility and will be removed in a future release. Arg...
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/openapi_generator.py#L484-L518
cloudendpoints/endpoints-python
endpoints/openapi_generator.py
OpenApiGenerator.__params_descriptor
def __params_descriptor(self, message_type, request_kind, path, method_id): """Describe the parameters of a method. If the message_type is not a ResourceContainer, will fall back to __params_descriptor_without_container (which will eventually be deprecated). If the message type is a ResourceContainer,...
python
def __params_descriptor(self, message_type, request_kind, path, method_id): """Describe the parameters of a method. If the message_type is not a ResourceContainer, will fall back to __params_descriptor_without_container (which will eventually be deprecated). If the message type is a ResourceContainer,...
Describe the parameters of a method. If the message_type is not a ResourceContainer, will fall back to __params_descriptor_without_container (which will eventually be deprecated). If the message type is a ResourceContainer, then all path/query parameters will come from the ResourceContainer. This meth...
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/openapi_generator.py#L520-L574
cloudendpoints/endpoints-python
endpoints/openapi_generator.py
OpenApiGenerator.__request_message_descriptor
def __request_message_descriptor(self, request_kind, message_type, method_id, path): """Describes the parameters and body of the request. Args: request_kind: The type of request being made. message_type: messages.Message or ResourceContainer class. The message to ...
python
def __request_message_descriptor(self, request_kind, message_type, method_id, path): """Describes the parameters and body of the request. Args: request_kind: The type of request being made. message_type: messages.Message or ResourceContainer class. The message to ...
Describes the parameters and body of the request. Args: request_kind: The type of request being made. message_type: messages.Message or ResourceContainer class. The message to describe. method_id: string, Unique method identifier (e.g. 'myapi.items.method') path: string, HTTP path...
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/openapi_generator.py#L576-L611
cloudendpoints/endpoints-python
endpoints/openapi_generator.py
OpenApiGenerator.__definitions_descriptor
def __definitions_descriptor(self): """Describes the definitions section of the OpenAPI spec. Returns: Dictionary describing the definitions of the spec. """ # Filter out any keys that aren't 'properties' or 'type' result = {} for def_key, def_value in self.__parser.schemas().iteritems():...
python
def __definitions_descriptor(self): """Describes the definitions section of the OpenAPI spec. Returns: Dictionary describing the definitions of the spec. """ # Filter out any keys that aren't 'properties' or 'type' result = {} for def_key, def_value in self.__parser.schemas().iteritems():...
Describes the definitions section of the OpenAPI spec. Returns: Dictionary describing the definitions of the spec.
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/openapi_generator.py#L613-L647
cloudendpoints/endpoints-python
endpoints/openapi_generator.py
OpenApiGenerator.__response_message_descriptor
def __response_message_descriptor(self, message_type, method_id): """Describes the response. Args: message_type: messages.Message class, The message to describe. method_id: string, Unique method identifier (e.g. 'myapi.items.method') Returns: Dictionary describing the response. """ ...
python
def __response_message_descriptor(self, message_type, method_id): """Describes the response. Args: message_type: messages.Message class, The message to describe. method_id: string, Unique method identifier (e.g. 'myapi.items.method') Returns: Dictionary describing the response. """ ...
Describes the response. Args: message_type: messages.Message class, The message to describe. method_id: string, Unique method identifier (e.g. 'myapi.items.method') Returns: Dictionary describing the response.
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/openapi_generator.py#L649-L670
cloudendpoints/endpoints-python
endpoints/openapi_generator.py
OpenApiGenerator.__x_google_quota_descriptor
def __x_google_quota_descriptor(self, metric_costs): """Describes the metric costs for a call. Args: metric_costs: Dict of metric definitions to the integer cost value against that metric. Returns: A dict descriptor describing the Quota limits for the endpoint. """ return { ...
python
def __x_google_quota_descriptor(self, metric_costs): """Describes the metric costs for a call. Args: metric_costs: Dict of metric definitions to the integer cost value against that metric. Returns: A dict descriptor describing the Quota limits for the endpoint. """ return { ...
Describes the metric costs for a call. Args: metric_costs: Dict of metric definitions to the integer cost value against that metric. Returns: A dict descriptor describing the Quota limits for the endpoint.
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/openapi_generator.py#L672-L686
cloudendpoints/endpoints-python
endpoints/openapi_generator.py
OpenApiGenerator.__x_google_quota_definitions_descriptor
def __x_google_quota_definitions_descriptor(self, limit_definitions): """Describes the quota limit definitions for an API. Args: limit_definitions: List of endpoints.LimitDefinition tuples Returns: A dict descriptor of the API's quota limit definitions. """ if not limit_definitions: ...
python
def __x_google_quota_definitions_descriptor(self, limit_definitions): """Describes the quota limit definitions for an API. Args: limit_definitions: List of endpoints.LimitDefinition tuples Returns: A dict descriptor of the API's quota limit definitions. """ if not limit_definitions: ...
Describes the quota limit definitions for an API. Args: limit_definitions: List of endpoints.LimitDefinition tuples Returns: A dict descriptor of the API's quota limit definitions.
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/openapi_generator.py#L688-L717
cloudendpoints/endpoints-python
endpoints/openapi_generator.py
OpenApiGenerator.__method_descriptor
def __method_descriptor(self, service, method_info, operation_id, protorpc_method_info, security_definitions): """Describes a method. Args: service: endpoints.Service, Implementation of the API as a service. method_info: _MethodInfo, Configuration for the method. ope...
python
def __method_descriptor(self, service, method_info, operation_id, protorpc_method_info, security_definitions): """Describes a method. Args: service: endpoints.Service, Implementation of the API as a service. method_info: _MethodInfo, Configuration for the method. ope...
Describes a method. Args: service: endpoints.Service, Implementation of the API as a service. method_info: _MethodInfo, Configuration for the method. operation_id: string, Operation ID of the method protorpc_method_info: protorpc.remote._RemoteMethodInfo, ProtoRPC description of the...
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/openapi_generator.py#L719-L767
cloudendpoints/endpoints-python
endpoints/openapi_generator.py
OpenApiGenerator.__security_definitions_descriptor
def __security_definitions_descriptor(self, issuers): """Create a descriptor for the security definitions. Args: issuers: dict, mapping issuer names to Issuer tuples Returns: The dict representing the security definitions descriptor. """ if not issuers: result = { _DEFA...
python
def __security_definitions_descriptor(self, issuers): """Create a descriptor for the security definitions. Args: issuers: dict, mapping issuer names to Issuer tuples Returns: The dict representing the security definitions descriptor. """ if not issuers: result = { _DEFA...
Create a descriptor for the security definitions. Args: issuers: dict, mapping issuer names to Issuer tuples Returns: The dict representing the security definitions descriptor.
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/openapi_generator.py#L818-L854
cloudendpoints/endpoints-python
endpoints/openapi_generator.py
OpenApiGenerator.__api_openapi_descriptor
def __api_openapi_descriptor(self, services, hostname=None, x_google_api_name=False): """Builds an OpenAPI description of an API. Args: services: List of protorpc.remote.Service instances implementing an api/version. hostname: string, Hostname of the API, to override the value set on the ...
python
def __api_openapi_descriptor(self, services, hostname=None, x_google_api_name=False): """Builds an OpenAPI description of an API. Args: services: List of protorpc.remote.Service instances implementing an api/version. hostname: string, Hostname of the API, to override the value set on the ...
Builds an OpenAPI description of an API. Args: services: List of protorpc.remote.Service instances implementing an api/version. hostname: string, Hostname of the API, to override the value set on the current service. Defaults to None. Returns: A dictionary that can be deseria...
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/openapi_generator.py#L883-L993
cloudendpoints/endpoints-python
endpoints/openapi_generator.py
OpenApiGenerator.get_descriptor_defaults
def get_descriptor_defaults(self, api_info, hostname=None, x_google_api_name=False): """Gets a default configuration for a service. Args: api_info: _ApiInfo object for this service. hostname: string, Hostname of the API, to override the value set on the current service. Defaults to None. ...
python
def get_descriptor_defaults(self, api_info, hostname=None, x_google_api_name=False): """Gets a default configuration for a service. Args: api_info: _ApiInfo object for this service. hostname: string, Hostname of the API, to override the value set on the current service. Defaults to None. ...
Gets a default configuration for a service. Args: api_info: _ApiInfo object for this service. hostname: string, Hostname of the API, to override the value set on the current service. Defaults to None. Returns: A dictionary with the default configuration.
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/openapi_generator.py#L995-L1029
cloudendpoints/endpoints-python
endpoints/openapi_generator.py
OpenApiGenerator.get_openapi_dict
def get_openapi_dict(self, services, hostname=None, x_google_api_name=False): """JSON dict description of a protorpc.remote.Service in OpenAPI format. Args: services: Either a single protorpc.remote.Service or a list of them that implements an api/version. hostname: string, Hostname of the ...
python
def get_openapi_dict(self, services, hostname=None, x_google_api_name=False): """JSON dict description of a protorpc.remote.Service in OpenAPI format. Args: services: Either a single protorpc.remote.Service or a list of them that implements an api/version. hostname: string, Hostname of the ...
JSON dict description of a protorpc.remote.Service in OpenAPI format. Args: services: Either a single protorpc.remote.Service or a list of them that implements an api/version. hostname: string, Hostname of the API, to override the value set on the current service. Defaults to None. ...
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/openapi_generator.py#L1031-L1053
cloudendpoints/endpoints-python
endpoints/openapi_generator.py
OpenApiGenerator.pretty_print_config_to_json
def pretty_print_config_to_json(self, services, hostname=None, x_google_api_name=False): """JSON string description of a protorpc.remote.Service in OpenAPI format. Args: services: Either a single protorpc.remote.Service or a list of them that implements an api/version. hostname: string, Hos...
python
def pretty_print_config_to_json(self, services, hostname=None, x_google_api_name=False): """JSON string description of a protorpc.remote.Service in OpenAPI format. Args: services: Either a single protorpc.remote.Service or a list of them that implements an api/version. hostname: string, Hos...
JSON string description of a protorpc.remote.Service in OpenAPI format. Args: services: Either a single protorpc.remote.Service or a list of them that implements an api/version. hostname: string, Hostname of the API, to override the value set on the current service. Defaults to None. ...
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/openapi_generator.py#L1055-L1069
cloudendpoints/endpoints-python
endpoints/protojson.py
EndpointsProtoJson.encode_field
def encode_field(self, field, value): """Encode a python field value to a JSON value. Args: field: A ProtoRPC field instance. value: A python value supported by field. Returns: A JSON serializable value appropriate for field. """ # Override the handling of 64-bit integers, so the...
python
def encode_field(self, field, value): """Encode a python field value to a JSON value. Args: field: A ProtoRPC field instance. value: A python value supported by field. Returns: A JSON serializable value appropriate for field. """ # Override the handling of 64-bit integers, so the...
Encode a python field value to a JSON value. Args: field: A ProtoRPC field instance. value: A python value supported by field. Returns: A JSON serializable value appropriate for field.
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/protojson.py#L41-L65
cloudendpoints/endpoints-python
endpoints/protojson.py
EndpointsProtoJson.__pad_value
def __pad_value(value, pad_len_multiple, pad_char): """Add padding characters to the value if needed. Args: value: The string value to be padded. pad_len_multiple: Pad the result so its length is a multiple of pad_len_multiple. pad_char: The character to use for padding. Return...
python
def __pad_value(value, pad_len_multiple, pad_char): """Add padding characters to the value if needed. Args: value: The string value to be padded. pad_len_multiple: Pad the result so its length is a multiple of pad_len_multiple. pad_char: The character to use for padding. Return...
Add padding characters to the value if needed. Args: value: The string value to be padded. pad_len_multiple: Pad the result so its length is a multiple of pad_len_multiple. pad_char: The character to use for padding. Returns: The string value with padding characters added.
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/protojson.py#L68-L84
cloudendpoints/endpoints-python
endpoints/protojson.py
EndpointsProtoJson.decode_field
def decode_field(self, field, value): """Decode a JSON value to a python value. Args: field: A ProtoRPC field instance. value: A serialized JSON value. Returns: A Python value compatible with field. """ # Override BytesField handling. Client libraries typically use a url-safe ...
python
def decode_field(self, field, value): """Decode a JSON value to a python value. Args: field: A ProtoRPC field instance. value: A serialized JSON value. Returns: A Python value compatible with field. """ # Override BytesField handling. Client libraries typically use a url-safe ...
Decode a JSON value to a python value. Args: field: A ProtoRPC field instance. value: A serialized JSON value. Returns: A Python value compatible with field.
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/protojson.py#L86-L108
cloudendpoints/endpoints-python
endpoints/message_parser.py
MessageTypeToJsonSchema.add_message
def add_message(self, message_type): """Add a new message. Args: message_type: protorpc.message.Message class to be parsed. Returns: string, The JSON Schema id. Raises: KeyError if the Schema id for this message_type would collide with the Schema id of a different message_type...
python
def add_message(self, message_type): """Add a new message. Args: message_type: protorpc.message.Message class to be parsed. Returns: string, The JSON Schema id. Raises: KeyError if the Schema id for this message_type would collide with the Schema id of a different message_type...
Add a new message. Args: message_type: protorpc.message.Message class to be parsed. Returns: string, The JSON Schema id. Raises: KeyError if the Schema id for this message_type would collide with the Schema id of a different message_type that was already added.
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/message_parser.py#L74-L93
cloudendpoints/endpoints-python
endpoints/message_parser.py
MessageTypeToJsonSchema.ref_for_message_type
def ref_for_message_type(self, message_type): """Returns the JSON Schema id for the given message. Args: message_type: protorpc.message.Message class to be parsed. Returns: string, The JSON Schema id. Raises: KeyError: if the message hasn't been parsed via add_message(). """ ...
python
def ref_for_message_type(self, message_type): """Returns the JSON Schema id for the given message. Args: message_type: protorpc.message.Message class to be parsed. Returns: string, The JSON Schema id. Raises: KeyError: if the message hasn't been parsed via add_message(). """ ...
Returns the JSON Schema id for the given message. Args: message_type: protorpc.message.Message class to be parsed. Returns: string, The JSON Schema id. Raises: KeyError: if the message hasn't been parsed via add_message().
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/message_parser.py#L95-L110
cloudendpoints/endpoints-python
endpoints/message_parser.py
MessageTypeToJsonSchema.__normalized_name
def __normalized_name(self, message_type): """Normalized schema name. Generate a normalized schema name, taking the class name and stripping out everything but alphanumerics, and camel casing the remaining words. A normalized schema name is a name that matches [a-zA-Z][a-zA-Z0-9]* Args: mess...
python
def __normalized_name(self, message_type): """Normalized schema name. Generate a normalized schema name, taking the class name and stripping out everything but alphanumerics, and camel casing the remaining words. A normalized schema name is a name that matches [a-zA-Z][a-zA-Z0-9]* Args: mess...
Normalized schema name. Generate a normalized schema name, taking the class name and stripping out everything but alphanumerics, and camel casing the remaining words. A normalized schema name is a name that matches [a-zA-Z][a-zA-Z0-9]* Args: message_type: protorpc.message.Message class being par...
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/message_parser.py#L120-L152
cloudendpoints/endpoints-python
endpoints/message_parser.py
MessageTypeToJsonSchema.__message_to_schema
def __message_to_schema(self, message_type): """Parse a single message into JSON Schema. Will recursively descend the message structure and also parse other messages references via MessageFields. Args: message_type: protorpc.messages.Message class to parse. Returns: An object represen...
python
def __message_to_schema(self, message_type): """Parse a single message into JSON Schema. Will recursively descend the message structure and also parse other messages references via MessageFields. Args: message_type: protorpc.messages.Message class to parse. Returns: An object represen...
Parse a single message into JSON Schema. Will recursively descend the message structure and also parse other messages references via MessageFields. Args: message_type: protorpc.messages.Message class to parse. Returns: An object representation of the schema.
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/message_parser.py#L154-L227
cloudendpoints/endpoints-python
endpoints/parameter_converter.py
_check_enum
def _check_enum(parameter_name, value, parameter_config): """Checks if an enum value is valid. This is called by the transform_parameter_value function and shouldn't be called directly. This verifies that the value of an enum parameter is valid. Args: parameter_name: A string containing the name of the...
python
def _check_enum(parameter_name, value, parameter_config): """Checks if an enum value is valid. This is called by the transform_parameter_value function and shouldn't be called directly. This verifies that the value of an enum parameter is valid. Args: parameter_name: A string containing the name of the...
Checks if an enum value is valid. This is called by the transform_parameter_value function and shouldn't be called directly. This verifies that the value of an enum parameter is valid. Args: parameter_name: A string containing the name of the parameter, which is either just a variable name or the n...
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/parameter_converter.py#L30-L55
cloudendpoints/endpoints-python
endpoints/parameter_converter.py
_check_boolean
def _check_boolean(parameter_name, value, parameter_config): """Checks if a boolean value is valid. This is called by the transform_parameter_value function and shouldn't be called directly. This checks that the string value passed in can be converted to a valid boolean value. Args: parameter_name: A...
python
def _check_boolean(parameter_name, value, parameter_config): """Checks if a boolean value is valid. This is called by the transform_parameter_value function and shouldn't be called directly. This checks that the string value passed in can be converted to a valid boolean value. Args: parameter_name: A...
Checks if a boolean value is valid. This is called by the transform_parameter_value function and shouldn't be called directly. This checks that the string value passed in can be converted to a valid boolean value. Args: parameter_name: A string containing the name of the parameter, which is eithe...
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/parameter_converter.py#L58-L84
cloudendpoints/endpoints-python
endpoints/parameter_converter.py
_get_parameter_conversion_entry
def _get_parameter_conversion_entry(parameter_config): """Get information needed to convert the given parameter to its API type. Args: parameter_config: The dictionary containing information specific to the parameter in question. This is retrieved from request.parameters in the method config. Re...
python
def _get_parameter_conversion_entry(parameter_config): """Get information needed to convert the given parameter to its API type. Args: parameter_config: The dictionary containing information specific to the parameter in question. This is retrieved from request.parameters in the method config. Re...
Get information needed to convert the given parameter to its API type. Args: parameter_config: The dictionary containing information specific to the parameter in question. This is retrieved from request.parameters in the method config. Returns: The entry from _PARAM_CONVERSION_MAP with functio...
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/parameter_converter.py#L126-L147
cloudendpoints/endpoints-python
endpoints/parameter_converter.py
transform_parameter_value
def transform_parameter_value(parameter_name, value, parameter_config): """Validates and transforms parameters to the type expected by the API. If the value is a list this will recursively call _transform_parameter_value on the values in the list. Otherwise, it checks all parameter rules for the the current va...
python
def transform_parameter_value(parameter_name, value, parameter_config): """Validates and transforms parameters to the type expected by the API. If the value is a list this will recursively call _transform_parameter_value on the values in the list. Otherwise, it checks all parameter rules for the the current va...
Validates and transforms parameters to the type expected by the API. If the value is a list this will recursively call _transform_parameter_value on the values in the list. Otherwise, it checks all parameter rules for the the current value and converts its type from a string to whatever format the API expects....
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/parameter_converter.py#L150-L200
django-leonardo/django-leonardo
leonardo/module/web/management/commands/dumpweb.py
sort_dependencies
def sort_dependencies(app_list): """Sort a list of (app_config, models) pairs into a single list of models. The single list of models is sorted so that any model with a natural key is serialized before a normal model, and any model with a natural key dependency has it's dependencies serialized first. ...
python
def sort_dependencies(app_list): """Sort a list of (app_config, models) pairs into a single list of models. The single list of models is sorted so that any model with a natural key is serialized before a normal model, and any model with a natural key dependency has it's dependencies serialized first. ...
Sort a list of (app_config, models) pairs into a single list of models. The single list of models is sorted so that any model with a natural key is serialized before a normal model, and any model with a natural key dependency has it's dependencies serialized first.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/management/commands/dumpweb.py#L170-L241
django-leonardo/django-leonardo
leonardo/module/nav/mixins.py
NavigationWidgetMixin.filter_items
def filter_items(self, items): '''perform filtering items by specific criteria''' items = self._filter_active(items) items = self._filter_in_nav(items) return items
python
def filter_items(self, items): '''perform filtering items by specific criteria''' items = self._filter_active(items) items = self._filter_in_nav(items) return items
perform filtering items by specific criteria
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/nav/mixins.py#L38-L42
django-leonardo/django-leonardo
leonardo/module/media/admin/file/tables.py
FilesTable.get_formset
def get_formset(self): """Provide the formset corresponding to this DataTable. Use this to validate the formset and to get the submitted data back. """ if self.folder: queryset = self.folder.files.all() else: queryset = File.objects.none() if self...
python
def get_formset(self): """Provide the formset corresponding to this DataTable. Use this to validate the formset and to get the submitted data back. """ if self.folder: queryset = self.folder.files.all() else: queryset = File.objects.none() if self...
Provide the formset corresponding to this DataTable. Use this to validate the formset and to get the submitted data back.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/media/admin/file/tables.py#L28-L43
django-leonardo/django-leonardo
leonardo/module/media/management/commands/import_files.py
FileImporter.import_file
def import_file(self, file_obj, folder): """ Create a File or an Image into the given folder """ created = False for cls in MEDIA_MODELS: if cls.matches_file_type(file_obj.name): obj, created = cls.objects.get_or_create( original_f...
python
def import_file(self, file_obj, folder): """ Create a File or an Image into the given folder """ created = False for cls in MEDIA_MODELS: if cls.matches_file_type(file_obj.name): obj, created = cls.objects.get_or_create( original_f...
Create a File or an Image into the given folder
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/media/management/commands/import_files.py#L26-L53
django-leonardo/django-leonardo
leonardo/utils/__init__.py
is_leonardo_module
def is_leonardo_module(mod): """returns True if is leonardo module """ if hasattr(mod, 'default') \ or hasattr(mod, 'leonardo_module_conf'): return True for key in dir(mod): if 'LEONARDO' in key: return True return False
python
def is_leonardo_module(mod): """returns True if is leonardo module """ if hasattr(mod, 'default') \ or hasattr(mod, 'leonardo_module_conf'): return True for key in dir(mod): if 'LEONARDO' in key: return True return False
returns True if is leonardo module
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/__init__.py#L12-L22
django-leonardo/django-leonardo
leonardo/module/nav/templatetags/webcms_nav_tags.py
_translate_page_into
def _translate_page_into(page, language, default=None): """ Return the translation for a given page """ # Optimisation shortcut: No need to dive into translations if page already what we want if page.language == language: return page translations = dict((t.language, t) for t in page.ava...
python
def _translate_page_into(page, language, default=None): """ Return the translation for a given page """ # Optimisation shortcut: No need to dive into translations if page already what we want if page.language == language: return page translations = dict((t.language, t) for t in page.ava...
Return the translation for a given page
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/nav/templatetags/webcms_nav_tags.py#L182-L198
django-leonardo/django-leonardo
leonardo/module/nav/templatetags/webcms_nav_tags.py
feincms_breadcrumbs
def feincms_breadcrumbs(page, include_self=True): """ Generate a list of the page's ancestors suitable for use as breadcrumb navigation. By default, generates an unordered list with the id "breadcrumbs" - override breadcrumbs.html to change this. :: {% feincms_breadcrumbs feincms_page %} ...
python
def feincms_breadcrumbs(page, include_self=True): """ Generate a list of the page's ancestors suitable for use as breadcrumb navigation. By default, generates an unordered list with the id "breadcrumbs" - override breadcrumbs.html to change this. :: {% feincms_breadcrumbs feincms_page %} ...
Generate a list of the page's ancestors suitable for use as breadcrumb navigation. By default, generates an unordered list with the id "breadcrumbs" - override breadcrumbs.html to change this. :: {% feincms_breadcrumbs feincms_page %}
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/nav/templatetags/webcms_nav_tags.py#L245-L267
django-leonardo/django-leonardo
leonardo/module/nav/templatetags/webcms_nav_tags.py
is_parent_of
def is_parent_of(page1, page2): """ Determines whether a given page is the parent of another page Example:: {% if page|is_parent_of:feincms_page %} ... {% endif %} """ try: return page1.tree_id == page2.tree_id and page1.lft < page2.lft and page1.rght > page2.rght except Attri...
python
def is_parent_of(page1, page2): """ Determines whether a given page is the parent of another page Example:: {% if page|is_parent_of:feincms_page %} ... {% endif %} """ try: return page1.tree_id == page2.tree_id and page1.lft < page2.lft and page1.rght > page2.rght except Attri...
Determines whether a given page is the parent of another page Example:: {% if page|is_parent_of:feincms_page %} ... {% endif %}
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/nav/templatetags/webcms_nav_tags.py#L271-L283
django-leonardo/django-leonardo
leonardo/module/web/page/views.py
PageCreateView.parent
def parent(self): '''We use parent for some initial data''' if not hasattr(self, '_parent'): if 'parent' in self.kwargs: try: self._parent = Page.objects.get(id=self.kwargs["parent"]) except Exception as e: raise e ...
python
def parent(self): '''We use parent for some initial data''' if not hasattr(self, '_parent'): if 'parent' in self.kwargs: try: self._parent = Page.objects.get(id=self.kwargs["parent"]) except Exception as e: raise e ...
We use parent for some initial data
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/page/views.py#L23-L40
django-leonardo/django-leonardo
leonardo/templatetags/leonardo_tags.py
head_title
def head_title(request): """ {% head_title request %} """ try: fragments = request._feincms_fragments except: fragments = {} if '_head_title' in fragments and fragments.get("_head_title"): return fragments.get("_head_title") else: # append site name s...
python
def head_title(request): """ {% head_title request %} """ try: fragments = request._feincms_fragments except: fragments = {} if '_head_title' in fragments and fragments.get("_head_title"): return fragments.get("_head_title") else: # append site name s...
{% head_title request %}
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/templatetags/leonardo_tags.py#L44-L65
django-leonardo/django-leonardo
leonardo/templatetags/leonardo_tags.py
meta_description
def meta_description(request): """ {% meta_description request %} """ try: fragments = request._feincms_fragments except: fragments = {} if '_meta_description' in fragments and fragments.get("_meta_description"): return fragments.get("_meta_description") else: ...
python
def meta_description(request): """ {% meta_description request %} """ try: fragments = request._feincms_fragments except: fragments = {} if '_meta_description' in fragments and fragments.get("_meta_description"): return fragments.get("_meta_description") else: ...
{% meta_description request %}
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/templatetags/leonardo_tags.py#L69-L90
django-leonardo/django-leonardo
leonardo/templatetags/leonardo_tags.py
render_region_tools
def render_region_tools(context, feincms_object, region, request=None): """ {% render_region_tools feincms_page "main" request %} skip rendering in standalone mode """ if context.get('standalone', False) or not feincms_object: return {} edit = False if getattr(settings, 'LEONARDO...
python
def render_region_tools(context, feincms_object, region, request=None): """ {% render_region_tools feincms_page "main" request %} skip rendering in standalone mode """ if context.get('standalone', False) or not feincms_object: return {} edit = False if getattr(settings, 'LEONARDO...
{% render_region_tools feincms_page "main" request %} skip rendering in standalone mode
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/templatetags/leonardo_tags.py#L95-L126
django-leonardo/django-leonardo
leonardo/templatetags/leonardo_tags.py
feincms_render_region
def feincms_render_region(context, feincms_object, region, request=None, classes='', wrapper=True): """ {% feincms_render_region feincms_page "main" request %} Support for rendering Page without some regions especialy for modals this feature is driven by context variable "...
python
def feincms_render_region(context, feincms_object, region, request=None, classes='', wrapper=True): """ {% feincms_render_region feincms_page "main" request %} Support for rendering Page without some regions especialy for modals this feature is driven by context variable "...
{% feincms_render_region feincms_page "main" request %} Support for rendering Page without some regions especialy for modals this feature is driven by context variable
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/templatetags/leonardo_tags.py#L162-L197
django-leonardo/django-leonardo
leonardo/templatetags/leonardo_tags.py
app_reverse
def app_reverse(parser, token): """ Returns an absolute URL for applications integrated with ApplicationContent The tag mostly works the same way as Django's own {% url %} tag:: {% load leonardo_tags %} {% app_reverse "mymodel_detail" "myapp.urls" arg1 arg2 %} or {% load leon...
python
def app_reverse(parser, token): """ Returns an absolute URL for applications integrated with ApplicationContent The tag mostly works the same way as Django's own {% url %} tag:: {% load leonardo_tags %} {% app_reverse "mymodel_detail" "myapp.urls" arg1 arg2 %} or {% load leon...
Returns an absolute URL for applications integrated with ApplicationContent The tag mostly works the same way as Django's own {% url %} tag:: {% load leonardo_tags %} {% app_reverse "mymodel_detail" "myapp.urls" arg1 arg2 %} or {% load leonardo_tags %} {% app_reverse "mymodel...
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/templatetags/leonardo_tags.py#L234-L281
django-leonardo/django-leonardo
leonardo/templatetags/leonardo_tags.py
feincms_object_tools
def feincms_object_tools(context, cls_name): """ {% feincms_object_tools 'article' %} {% feincms_object_tools 'web.page' %} render add feincms object entry """ if context.get('standalone', False): return {} edit = False if getattr(settings, 'LEONARDO_USE_PAGE_ADMIN', False): ...
python
def feincms_object_tools(context, cls_name): """ {% feincms_object_tools 'article' %} {% feincms_object_tools 'web.page' %} render add feincms object entry """ if context.get('standalone', False): return {} edit = False if getattr(settings, 'LEONARDO_USE_PAGE_ADMIN', False): ...
{% feincms_object_tools 'article' %} {% feincms_object_tools 'web.page' %} render add feincms object entry
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/templatetags/leonardo_tags.py#L286-L308
django-leonardo/django-leonardo
leonardo/templatetags/leonardo_tags.py
image_name
def image_name(image, key='name', clear=True): """ {{ image|image_name }} {{ image|image_name:"description" }} {{ image|image_name:"default_caption" }} {{ image|image_name:"default_caption" False }} Return translation or image name """ if hasattr(image, 'translation') and image.translat...
python
def image_name(image, key='name', clear=True): """ {{ image|image_name }} {{ image|image_name:"description" }} {{ image|image_name:"default_caption" }} {{ image|image_name:"default_caption" False }} Return translation or image name """ if hasattr(image, 'translation') and image.translat...
{{ image|image_name }} {{ image|image_name:"description" }} {{ image|image_name:"default_caption" }} {{ image|image_name:"default_caption" False }} Return translation or image name
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/templatetags/leonardo_tags.py#L322-L345
django-leonardo/django-leonardo
leonardo/module/web/models/page.py
Page.tree_label
def tree_label(self): '''render tree label like as `root > child > child`''' titles = [] page = self while page: titles.append(page.title) page = page.parent return smart_text(' > '.join(reversed(titles)))
python
def tree_label(self): '''render tree label like as `root > child > child`''' titles = [] page = self while page: titles.append(page.title) page = page.parent return smart_text(' > '.join(reversed(titles)))
render tree label like as `root > child > child`
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/models/page.py#L104-L111
django-leonardo/django-leonardo
leonardo/module/web/models/page.py
Page.flush_ct_inventory
def flush_ct_inventory(self): """internal method used only if ct_inventory is enabled """ if hasattr(self, '_ct_inventory'): # skip self from update self._ct_inventory = None self.update_view = False self.save()
python
def flush_ct_inventory(self): """internal method used only if ct_inventory is enabled """ if hasattr(self, '_ct_inventory'): # skip self from update self._ct_inventory = None self.update_view = False self.save()
internal method used only if ct_inventory is enabled
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/models/page.py#L164-L172
django-leonardo/django-leonardo
leonardo/module/web/models/page.py
Page.register_default_processors
def register_default_processors(cls, frontend_editing=None): """ Register our default request processors for the out-of-the-box Page experience. Since FeinCMS 1.11 was removed from core. """ super(Page, cls).register_default_processors() if frontend_editing: ...
python
def register_default_processors(cls, frontend_editing=None): """ Register our default request processors for the out-of-the-box Page experience. Since FeinCMS 1.11 was removed from core. """ super(Page, cls).register_default_processors() if frontend_editing: ...
Register our default request processors for the out-of-the-box Page experience. Since FeinCMS 1.11 was removed from core.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/models/page.py#L179-L195
django-leonardo/django-leonardo
leonardo/module/web/models/page.py
Page.run_request_processors
def run_request_processors(self, request): """ Before rendering a page, run all registered request processors. A request processor may peruse and modify the page or the request. It can also return a ``HttpResponse`` for shortcutting the rendering and returning that response immed...
python
def run_request_processors(self, request): """ Before rendering a page, run all registered request processors. A request processor may peruse and modify the page or the request. It can also return a ``HttpResponse`` for shortcutting the rendering and returning that response immed...
Before rendering a page, run all registered request processors. A request processor may peruse and modify the page or the request. It can also return a ``HttpResponse`` for shortcutting the rendering and returning that response immediately to the client.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/models/page.py#L197-L210
django-leonardo/django-leonardo
leonardo/module/web/models/page.py
Page.as_text
def as_text(self): '''Fetch and render all regions For search and test purposes just a prototype ''' from leonardo.templatetags.leonardo_tags import _render_content request = get_anonymous_request(self) content = '' try: for region in [re...
python
def as_text(self): '''Fetch and render all regions For search and test purposes just a prototype ''' from leonardo.templatetags.leonardo_tags import _render_content request = get_anonymous_request(self) content = '' try: for region in [re...
Fetch and render all regions For search and test purposes just a prototype
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/models/page.py#L213-L238
django-leonardo/django-leonardo
leonardo/views/debug.py
technical_404_response
def technical_404_response(request, exception): "Create a technical 404 error response. The exception should be the Http404." try: error_url = exception.args[0]['path'] except (IndexError, TypeError, KeyError): error_url = request.path_info[1:] # Trim leading slash try: tried =...
python
def technical_404_response(request, exception): "Create a technical 404 error response. The exception should be the Http404." try: error_url = exception.args[0]['path'] except (IndexError, TypeError, KeyError): error_url = request.path_info[1:] # Trim leading slash try: tried =...
Create a technical 404 error response. The exception should be the Http404.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/views/debug.py#L21-L98
django-leonardo/django-leonardo
leonardo/module/media/admin/file/admin.py
FileAdmin.response_change
def response_change(self, request, obj): """ Overrides the default to be able to forward to the directory listing instead of the default change_list_view """ r = super(FileAdmin, self).response_change(request, obj) if 'Location' in r and r['Location']: # it wa...
python
def response_change(self, request, obj): """ Overrides the default to be able to forward to the directory listing instead of the default change_list_view """ r = super(FileAdmin, self).response_change(request, obj) if 'Location' in r and r['Location']: # it wa...
Overrides the default to be able to forward to the directory listing instead of the default change_list_view
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/media/admin/file/admin.py#L56-L91
django-leonardo/django-leonardo
leonardo/module/media/admin/file/admin.py
FileAdmin.delete_view
def delete_view(self, request, object_id, extra_context=None): """ Overrides the default to enable redirecting to the directory view after deletion of a image. we need to fetch the object and find out who the parent is before super, because super will delete the object and make ...
python
def delete_view(self, request, object_id, extra_context=None): """ Overrides the default to enable redirecting to the directory view after deletion of a image. we need to fetch the object and find out who the parent is before super, because super will delete the object and make ...
Overrides the default to enable redirecting to the directory view after deletion of a image. we need to fetch the object and find out who the parent is before super, because super will delete the object and make it impossible to find out the parent folder to redirect to.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/media/admin/file/admin.py#L103-L138
django-leonardo/django-leonardo
leonardo/module/web/widgets/mixins.py
ListMixin.items
def items(self): '''access for filtered items''' if hasattr(self, '_items'): return self.filter_items(self._items) self._items = self.get_items() return self.filter_items(self._items)
python
def items(self): '''access for filtered items''' if hasattr(self, '_items'): return self.filter_items(self._items) self._items = self.get_items() return self.filter_items(self._items)
access for filtered items
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/mixins.py#L77-L82
django-leonardo/django-leonardo
leonardo/module/web/widgets/mixins.py
ListMixin.populate_items
def populate_items(self, request): '''populate and returns filtered items''' self._items = self.get_items(request) return self.items
python
def populate_items(self, request): '''populate and returns filtered items''' self._items = self.get_items(request) return self.items
populate and returns filtered items
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/mixins.py#L84-L87
django-leonardo/django-leonardo
leonardo/module/web/widgets/mixins.py
ListMixin.get_rows
def get_rows(self): '''returns rows with items [[item1 item2], [item3 item4], [item5]]''' rows = [] row = [] for i, item in enumerate(self.items): if i > 0 and i % self.objects_per_row == 0: rows.append(row) row = [] row.app...
python
def get_rows(self): '''returns rows with items [[item1 item2], [item3 item4], [item5]]''' rows = [] row = [] for i, item in enumerate(self.items): if i > 0 and i % self.objects_per_row == 0: rows.append(row) row = [] row.app...
returns rows with items [[item1 item2], [item3 item4], [item5]]
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/mixins.py#L90-L101
django-leonardo/django-leonardo
leonardo/module/web/widgets/mixins.py
ListMixin.columns_classes
def columns_classes(self): '''returns columns count''' md = 12 / self.objects_per_row sm = None if self.objects_per_row > 2: sm = 12 / (self.objects_per_row / 2) return md, (sm or md), 12
python
def columns_classes(self): '''returns columns count''' md = 12 / self.objects_per_row sm = None if self.objects_per_row > 2: sm = 12 / (self.objects_per_row / 2) return md, (sm or md), 12
returns columns count
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/mixins.py#L104-L110
django-leonardo/django-leonardo
leonardo/module/web/widgets/mixins.py
ListMixin.get_pages
def get_pages(self): '''returns pages with rows''' pages = [] page = [] for i, item in enumerate(self.get_rows): if i > 0 and i % self.objects_per_page == 0: pages.append(page) page = [] page.append(item) pages.append(page) ...
python
def get_pages(self): '''returns pages with rows''' pages = [] page = [] for i, item in enumerate(self.get_rows): if i > 0 and i % self.objects_per_page == 0: pages.append(page) page = [] page.append(item) pages.append(page) ...
returns pages with rows
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/mixins.py#L120-L130
django-leonardo/django-leonardo
leonardo/module/web/widgets/mixins.py
ListMixin.needs_pagination
def needs_pagination(self): """Calculate needs pagination""" if self.objects_per_page == 0: return False if len(self.items) > self.objects_per_page \ or len(self.get_pages[0]) > self.objects_per_page: return True return False
python
def needs_pagination(self): """Calculate needs pagination""" if self.objects_per_page == 0: return False if len(self.items) > self.objects_per_page \ or len(self.get_pages[0]) > self.objects_per_page: return True return False
Calculate needs pagination
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/mixins.py#L133-L140
django-leonardo/django-leonardo
leonardo/module/web/widgets/mixins.py
ListMixin.get_item_template
def get_item_template(self): '''returns template for signle object from queryset If you have a template name my_list_template.html then template for a single object will be _my_list_template.html Now only for default generates _item.html _item.html is obsolete use _defau...
python
def get_item_template(self): '''returns template for signle object from queryset If you have a template name my_list_template.html then template for a single object will be _my_list_template.html Now only for default generates _item.html _item.html is obsolete use _defau...
returns template for signle object from queryset If you have a template name my_list_template.html then template for a single object will be _my_list_template.html Now only for default generates _item.html _item.html is obsolete use _default.html
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/mixins.py#L148-L165
django-leonardo/django-leonardo
leonardo/module/web/widgets/mixins.py
ContentProxyWidgetMixin.is_obsolete
def is_obsolete(self): """returns True is data is obsolete and needs revalidation """ if self.cache_updated: now = timezone.now() delta = now - self.cache_updated if delta.seconds < self.cache_validity: return False return True
python
def is_obsolete(self): """returns True is data is obsolete and needs revalidation """ if self.cache_updated: now = timezone.now() delta = now - self.cache_updated if delta.seconds < self.cache_validity: return False return True
returns True is data is obsolete and needs revalidation
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/mixins.py#L224-L232
django-leonardo/django-leonardo
leonardo/module/web/widgets/mixins.py
ContentProxyWidgetMixin.update_cache
def update_cache(self, data=None): """call with new data or set data to self.cache_data and call this """ if data: self.cache_data = data self.cache_updated = timezone.now() self.save()
python
def update_cache(self, data=None): """call with new data or set data to self.cache_data and call this """ if data: self.cache_data = data self.cache_updated = timezone.now() self.save()
call with new data or set data to self.cache_data and call this
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/mixins.py#L234-L240
django-leonardo/django-leonardo
leonardo/module/web/widgets/mixins.py
ContentProxyWidgetMixin.data
def data(self): """this property just calls ``get_data`` but here you can serilalize your data or render as html these data will be saved to self.cached_content also will be accessable from template """ if self.is_obsolete(): self.update_cache(self.get_data())...
python
def data(self): """this property just calls ``get_data`` but here you can serilalize your data or render as html these data will be saved to self.cached_content also will be accessable from template """ if self.is_obsolete(): self.update_cache(self.get_data())...
this property just calls ``get_data`` but here you can serilalize your data or render as html these data will be saved to self.cached_content also will be accessable from template
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/mixins.py#L251-L259
django-leonardo/django-leonardo
leonardo/module/web/widgets/mixins.py
JSONContentMixin.data
def data(self): """load and cache data in json format """ if self.is_obsolete(): data = self.get_data() for datum in data: if 'published_parsed' in datum: datum['published_parsed'] = \ self.parse_time(datum['pub...
python
def data(self): """load and cache data in json format """ if self.is_obsolete(): data = self.get_data() for datum in data: if 'published_parsed' in datum: datum['published_parsed'] = \ self.parse_time(datum['pub...
load and cache data in json format
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/mixins.py#L274-L298
django-leonardo/django-leonardo
leonardo/utils/settings.py
get_loaded_modules
def get_loaded_modules(modules): '''load modules and order it by ordering key''' _modules = [] for mod in modules: mod_cfg = get_conf_from_module(mod) _modules.append((mod, mod_cfg,)) _modules = sorted(_modules, key=lambda m: m[1].get('ordering')) return _modules
python
def get_loaded_modules(modules): '''load modules and order it by ordering key''' _modules = [] for mod in modules: mod_cfg = get_conf_from_module(mod) _modules.append((mod, mod_cfg,)) _modules = sorted(_modules, key=lambda m: m[1].get('ordering')) return _modules
load modules and order it by ordering key
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/settings.py#L14-L25
django-leonardo/django-leonardo
leonardo/utils/settings.py
merge
def merge(a, b): """return merged tuples or lists without duplicates note: ensure if admin theme is before admin """ if isinstance(a, CONFIG_VALID) \ and isinstance(b, CONFIG_VALID): # dict update if isinstance(a, dict) and isinstance(b, dict): a.update(b) ...
python
def merge(a, b): """return merged tuples or lists without duplicates note: ensure if admin theme is before admin """ if isinstance(a, CONFIG_VALID) \ and isinstance(b, CONFIG_VALID): # dict update if isinstance(a, dict) and isinstance(b, dict): a.update(b) ...
return merged tuples or lists without duplicates note: ensure if admin theme is before admin
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/settings.py#L48-L66
django-leonardo/django-leonardo
leonardo/utils/settings.py
_is_leonardo_module
def _is_leonardo_module(whatever): '''check if is leonardo module''' # check if is python module if hasattr(whatever, 'default') \ or hasattr(whatever, 'leonardo_module_conf'): return True # check if is python object for key in dir(whatever): if 'LEONARDO' in key: ...
python
def _is_leonardo_module(whatever): '''check if is leonardo module''' # check if is python module if hasattr(whatever, 'default') \ or hasattr(whatever, 'leonardo_module_conf'): return True # check if is python object for key in dir(whatever): if 'LEONARDO' in key: ...
check if is leonardo module
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/settings.py#L69-L80
django-leonardo/django-leonardo
leonardo/utils/settings.py
extract_conf_from
def extract_conf_from(mod, conf=ModuleConfig(CONF_SPEC), depth=0, max_depth=2): """recursively extract keys from module or object by passed config scheme """ # extract config keys from module or object for key, default_value in six.iteritems(conf): conf[key] = _get_key_from_module(mod, key,...
python
def extract_conf_from(mod, conf=ModuleConfig(CONF_SPEC), depth=0, max_depth=2): """recursively extract keys from module or object by passed config scheme """ # extract config keys from module or object for key, default_value in six.iteritems(conf): conf[key] = _get_key_from_module(mod, key,...
recursively extract keys from module or object by passed config scheme
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/settings.py#L83-L118
django-leonardo/django-leonardo
leonardo/utils/settings.py
_get_correct_module
def _get_correct_module(mod): """returns imported module check if is ``leonardo_module_conf`` specified and then import them """ module_location = getattr( mod, 'leonardo_module_conf', getattr(mod, "LEONARDO_MODULE_CONF", None)) if module_location: mod = import_module(module...
python
def _get_correct_module(mod): """returns imported module check if is ``leonardo_module_conf`` specified and then import them """ module_location = getattr( mod, 'leonardo_module_conf', getattr(mod, "LEONARDO_MODULE_CONF", None)) if module_location: mod = import_module(module...
returns imported module check if is ``leonardo_module_conf`` specified and then import them
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/settings.py#L121-L141
django-leonardo/django-leonardo
leonardo/utils/settings.py
get_conf_from_module
def get_conf_from_module(mod): """return configuration from module with defaults no worry about None type """ conf = ModuleConfig(CONF_SPEC) # get imported module mod = _get_correct_module(mod) conf.set_module(mod) # extarct from default object or from module if hasattr(mod, 'defaul...
python
def get_conf_from_module(mod): """return configuration from module with defaults no worry about None type """ conf = ModuleConfig(CONF_SPEC) # get imported module mod = _get_correct_module(mod) conf.set_module(mod) # extarct from default object or from module if hasattr(mod, 'defaul...
return configuration from module with defaults no worry about None type
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/settings.py#L144-L162
django-leonardo/django-leonardo
leonardo/module/web/page/utils.py
get_anonymous_request
def get_anonymous_request(leonardo_page): """returns inicialized request """ request_factory = RequestFactory() request = request_factory.get( leonardo_page.get_absolute_url(), data={}) request.feincms_page = request.leonardo_page = leonardo_page request.frontend_editing = False req...
python
def get_anonymous_request(leonardo_page): """returns inicialized request """ request_factory = RequestFactory() request = request_factory.get( leonardo_page.get_absolute_url(), data={}) request.feincms_page = request.leonardo_page = leonardo_page request.frontend_editing = False req...
returns inicialized request
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/page/utils.py#L8-L43
django-leonardo/django-leonardo
leonardo/module/web/processors/font.py
webfont_cookie
def webfont_cookie(request): '''Adds WEBFONT Flag to the context''' if hasattr(request, 'COOKIES') and request.COOKIES.get(WEBFONT_COOKIE_NAME, None): return { WEBFONT_COOKIE_NAME.upper(): True } return { WEBFONT_COOKIE_NAME.upper(): False }
python
def webfont_cookie(request): '''Adds WEBFONT Flag to the context''' if hasattr(request, 'COOKIES') and request.COOKIES.get(WEBFONT_COOKIE_NAME, None): return { WEBFONT_COOKIE_NAME.upper(): True } return { WEBFONT_COOKIE_NAME.upper(): False }
Adds WEBFONT Flag to the context
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/processors/font.py#L10-L21
django-leonardo/django-leonardo
leonardo/messages.py
debug
def debug(request, message, extra_tags='', fail_silently=False, async=False): """Adds a message with the ``DEBUG`` level.""" if ASYNC and async: messages.debug(_get_user(request), message) else: add_message(request, constants.DEBUG, message, extra_tags=extra_tags, fail_si...
python
def debug(request, message, extra_tags='', fail_silently=False, async=False): """Adds a message with the ``DEBUG`` level.""" if ASYNC and async: messages.debug(_get_user(request), message) else: add_message(request, constants.DEBUG, message, extra_tags=extra_tags, fail_si...
Adds a message with the ``DEBUG`` level.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/messages.py#L52-L58
django-leonardo/django-leonardo
leonardo/messages.py
info
def info(request, message, extra_tags='', fail_silently=False, async=False): """Adds a message with the ``INFO`` level.""" if ASYNC and async: messages.info(_get_user(request), message) else: add_message(request, constants.INFO, message, extra_tags=extra_tags, fail_silent...
python
def info(request, message, extra_tags='', fail_silently=False, async=False): """Adds a message with the ``INFO`` level.""" if ASYNC and async: messages.info(_get_user(request), message) else: add_message(request, constants.INFO, message, extra_tags=extra_tags, fail_silent...
Adds a message with the ``INFO`` level.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/messages.py#L61-L67
django-leonardo/django-leonardo
leonardo/messages.py
success
def success(request, message, extra_tags='', fail_silently=False, async=False): """Adds a message with the ``SUCCESS`` level.""" if ASYNC and async: messages.success(_get_user(request), message) else: add_message(request, constants.SUCCESS, message, extra_tags=extra_tags, ...
python
def success(request, message, extra_tags='', fail_silently=False, async=False): """Adds a message with the ``SUCCESS`` level.""" if ASYNC and async: messages.success(_get_user(request), message) else: add_message(request, constants.SUCCESS, message, extra_tags=extra_tags, ...
Adds a message with the ``SUCCESS`` level.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/messages.py#L70-L76
django-leonardo/django-leonardo
leonardo/messages.py
warning
def warning(request, message, extra_tags='', fail_silently=False, async=False): """Adds a message with the ``WARNING`` level.""" if ASYNC and async: messages.debug(_get_user(request), message) else: add_message(request, constants.WARNING, message, extra_tags=extra_tags, f...
python
def warning(request, message, extra_tags='', fail_silently=False, async=False): """Adds a message with the ``WARNING`` level.""" if ASYNC and async: messages.debug(_get_user(request), message) else: add_message(request, constants.WARNING, message, extra_tags=extra_tags, f...
Adds a message with the ``WARNING`` level.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/messages.py#L79-L85
django-leonardo/django-leonardo
leonardo/messages.py
error
def error(request, message, extra_tags='', fail_silently=False, async=False): """Adds a message with the ``ERROR`` level.""" if ASYNC and async: messages.debug(_get_user(request), message) else: add_message(request, constants.ERROR, message, extra_tags=extra_tags, fail_si...
python
def error(request, message, extra_tags='', fail_silently=False, async=False): """Adds a message with the ``ERROR`` level.""" if ASYNC and async: messages.debug(_get_user(request), message) else: add_message(request, constants.ERROR, message, extra_tags=extra_tags, fail_si...
Adds a message with the ``ERROR`` level.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/messages.py#L88-L94
django-leonardo/django-leonardo
leonardo/utils/widgets.py
get_all_widget_classes
def get_all_widget_classes(): """returns collected Leonardo Widgets if not declared in settings is used __subclasses__ which not supports widget subclassing """ from leonardo.module.web.models import Widget _widgets = getattr(settings, 'WIDGETS', Widget.__subclasses__())...
python
def get_all_widget_classes(): """returns collected Leonardo Widgets if not declared in settings is used __subclasses__ which not supports widget subclassing """ from leonardo.module.web.models import Widget _widgets = getattr(settings, 'WIDGETS', Widget.__subclasses__())...
returns collected Leonardo Widgets if not declared in settings is used __subclasses__ which not supports widget subclassing
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/widgets.py#L45-L61
django-leonardo/django-leonardo
leonardo/utils/widgets.py
get_grouped_widgets
def get_grouped_widgets(feincms_object, request=None): '''returns tuple(choices, grouped, ungrouped) requires feincms_object for getting content types request optionaly for checking permissions, but not required grouped = {'web': (id, label, icon)} ''' grouped = {} ungrouped = [] cho...
python
def get_grouped_widgets(feincms_object, request=None): '''returns tuple(choices, grouped, ungrouped) requires feincms_object for getting content types request optionaly for checking permissions, but not required grouped = {'web': (id, label, icon)} ''' grouped = {} ungrouped = [] cho...
returns tuple(choices, grouped, ungrouped) requires feincms_object for getting content types request optionaly for checking permissions, but not required grouped = {'web': (id, label, icon)}
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/widgets.py#L64-L102
django-leonardo/django-leonardo
leonardo/utils/widgets.py
render_region
def render_region(widget=None, request=None, view=None, page=None, region=None): """returns rendered content this is not too clear and little tricky, because external apps needs calling process method """ # change the request if not isinstance(request, dict): request.q...
python
def render_region(widget=None, request=None, view=None, page=None, region=None): """returns rendered content this is not too clear and little tricky, because external apps needs calling process method """ # change the request if not isinstance(request, dict): request.q...
returns rendered content this is not too clear and little tricky, because external apps needs calling process method
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/widgets.py#L124-L173
django-leonardo/django-leonardo
leonardo/module/web/widgets/views.py
WidgetViewMixin.handle_dimensions
def handle_dimensions(self, obj): """save dimensions """ from .tables import WidgetDimensionFormset from ..models import WidgetDimension formset = WidgetDimensionFormset( self.request.POST, prefix='dimensions') if formset.is_valid(): formset.save(...
python
def handle_dimensions(self, obj): """save dimensions """ from .tables import WidgetDimensionFormset from ..models import WidgetDimension formset = WidgetDimensionFormset( self.request.POST, prefix='dimensions') if formset.is_valid(): formset.save(...
save dimensions
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/views.py#L28-L60
django-leonardo/django-leonardo
leonardo/module/web/widgets/views.py
WidgetUpdateView.get_form
def get_form(self, form_class): """Returns an instance of the form to be used in this view.""" if not hasattr(self, '_form'): kwargs = self.get_form_kwargs() self._form = form_class(**kwargs) return self._form
python
def get_form(self, form_class): """Returns an instance of the form to be used in this view.""" if not hasattr(self, '_form'): kwargs = self.get_form_kwargs() self._form = form_class(**kwargs) return self._form
Returns an instance of the form to be used in this view.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/views.py#L110-L115
django-leonardo/django-leonardo
leonardo/module/web/widgets/views.py
WidgetPreCreateView.get_form
def get_form(self, form_class): """Returns an instance of the form to be used in this view.""" kwargs = self.kwargs kwargs.update(self.get_form_kwargs()) kwargs.update({ 'request': self.request, 'next_view': WidgetCreateView }) return form_class(**...
python
def get_form(self, form_class): """Returns an instance of the form to be used in this view.""" kwargs = self.kwargs kwargs.update(self.get_form_kwargs()) kwargs.update({ 'request': self.request, 'next_view': WidgetCreateView }) return form_class(**...
Returns an instance of the form to be used in this view.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/views.py#L206-L214
django-leonardo/django-leonardo
leonardo/module/web/widgets/views.py
WidgetMoveView.get_form
def get_form(self, form_class): """Returns an instance of the form to be used in this view.""" if not hasattr(self, '_form'): kwargs = self.get_form_kwargs() self._form = form_class(instance=self.object, **kwargs) return self._form
python
def get_form(self, form_class): """Returns an instance of the form to be used in this view.""" if not hasattr(self, '_form'): kwargs = self.get_form_kwargs() self._form = form_class(instance=self.object, **kwargs) return self._form
Returns an instance of the form to be used in this view.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/views.py#L486-L491
django-leonardo/django-leonardo
leonardo/forms/fields/dynamic.py
DynamicSelectWidget.get_edit_handler
def get_edit_handler(self): '''TODO: Fix add-to-field''' # just a flag self.generic = 'false' return ''' <span class="input-group-btn"> <a href="#" id="item-edit-%(id)s" data-add-to-field="id_file" class="btn btn-default disabled"><span class="fa fa-pencil"></span><...
python
def get_edit_handler(self): '''TODO: Fix add-to-field''' # just a flag self.generic = 'false' return ''' <span class="input-group-btn"> <a href="#" id="item-edit-%(id)s" data-add-to-field="id_file" class="btn btn-default disabled"><span class="fa fa-pencil"></span><...
TODO: Fix add-to-field
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/forms/fields/dynamic.py#L116-L221
django-leonardo/django-leonardo
leonardo/module/web/admin.py
PageAdmin.get_feincms_inlines
def get_feincms_inlines(self, model, request): """ Generate genuine django inlines for registered content types. """ model._needs_content_types() inlines = [] for content_type in model._feincms_content_types: if not self.can_add_content(request, content_type): ...
python
def get_feincms_inlines(self, model, request): """ Generate genuine django inlines for registered content types. """ model._needs_content_types() inlines = [] for content_type in model._feincms_content_types: if not self.can_add_content(request, content_type): ...
Generate genuine django inlines for registered content types.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/admin.py#L49-L82
django-leonardo/django-leonardo
leonardo/module/web/admin.py
PageAdmin.get_changeform_initial_data
def get_changeform_initial_data(self, request): '''Copy initial data from parent''' initial = super(PageAdmin, self).get_changeform_initial_data(request) if ('translation_of' in request.GET): original = self.model._tree_manager.get( pk=request.GET.get('translation_of'...
python
def get_changeform_initial_data(self, request): '''Copy initial data from parent''' initial = super(PageAdmin, self).get_changeform_initial_data(request) if ('translation_of' in request.GET): original = self.model._tree_manager.get( pk=request.GET.get('translation_of'...
Copy initial data from parent
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/admin.py#L84-L103
django-leonardo/django-leonardo
leonardo/utils/package.py
install_package
def install_package(package, upgrade=True, target=None): """Install a package on PyPi. Accepts pip compatible package strings. Return boolean if install successful. """ # Not using 'import pip; pip.main([])' because it breaks the logger with INSTALL_LOCK: if check_packag...
python
def install_package(package, upgrade=True, target=None): """Install a package on PyPi. Accepts pip compatible package strings. Return boolean if install successful. """ # Not using 'import pip; pip.main([])' because it breaks the logger with INSTALL_LOCK: if check_packag...
Install a package on PyPi. Accepts pip compatible package strings. Return boolean if install successful.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/package.py#L19-L41
django-leonardo/django-leonardo
leonardo/utils/package.py
check_package_exists
def check_package_exists(package, lib_dir): """Check if a package is installed globally or in lib_dir. Returns True when the requirement is met. Returns False when the package is not installed or doesn't meet req. """ try: req = pkg_resources.Requirement.parse(package) except ValueError...
python
def check_package_exists(package, lib_dir): """Check if a package is installed globally or in lib_dir. Returns True when the requirement is met. Returns False when the package is not installed or doesn't meet req. """ try: req = pkg_resources.Requirement.parse(package) except ValueError...
Check if a package is installed globally or in lib_dir. Returns True when the requirement is met. Returns False when the package is not installed or doesn't meet req.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/package.py#L44-L64
django-leonardo/django-leonardo
leonardo/views/ajax.py
AJAXMixin.render_widget
def render_widget(self, request, widget_id): '''Returns rendered widget in JSON response''' widget = get_widget_from_id(widget_id) response = widget.render(**{'request': request}) return JsonResponse({'result': response, 'id': widget_id})
python
def render_widget(self, request, widget_id): '''Returns rendered widget in JSON response''' widget = get_widget_from_id(widget_id) response = widget.render(**{'request': request}) return JsonResponse({'result': response, 'id': widget_id})
Returns rendered widget in JSON response
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/views/ajax.py#L31-L38
django-leonardo/django-leonardo
leonardo/views/ajax.py
AJAXMixin.render_region
def render_region(self, request): '''Returns rendered region in JSON response''' page = self.get_object() try: region = request.POST['region'] except KeyError: region = request.GET['region'] request.query_string = None from leonardo.utils.widge...
python
def render_region(self, request): '''Returns rendered region in JSON response''' page = self.get_object() try: region = request.POST['region'] except KeyError: region = request.GET['region'] request.query_string = None from leonardo.utils.widge...
Returns rendered region in JSON response
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/views/ajax.py#L40-L56
django-leonardo/django-leonardo
leonardo/views/ajax.py
AJAXMixin.handle_ajax_method
def handle_ajax_method(self, request, method): """handle ajax methods and return serialized reponse in the default state allows only authentificated users - Depends on method parameter render whole region or single widget - If widget_id is present then try to load this widget ...
python
def handle_ajax_method(self, request, method): """handle ajax methods and return serialized reponse in the default state allows only authentificated users - Depends on method parameter render whole region or single widget - If widget_id is present then try to load this widget ...
handle ajax methods and return serialized reponse in the default state allows only authentificated users - Depends on method parameter render whole region or single widget - If widget_id is present then try to load this widget and call method on them - If class_name is prese...
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/views/ajax.py#L59-L160
django-leonardo/django-leonardo
leonardo/templatetags/leonardo_admin_tags.py
post_process_fieldsets
def post_process_fieldsets(context, fieldset): """ Removes a few fields from FeinCMS admin inlines, those being ``id``, ``DELETE`` and ``ORDER`` currently. Additionally, it ensures that dynamically added fields (i.e. ``ApplicationContent``'s ``admin_fields`` option) are shown. """ # abort if...
python
def post_process_fieldsets(context, fieldset): """ Removes a few fields from FeinCMS admin inlines, those being ``id``, ``DELETE`` and ``ORDER`` currently. Additionally, it ensures that dynamically added fields (i.e. ``ApplicationContent``'s ``admin_fields`` option) are shown. """ # abort if...
Removes a few fields from FeinCMS admin inlines, those being ``id``, ``DELETE`` and ``ORDER`` currently. Additionally, it ensures that dynamically added fields (i.e. ``ApplicationContent``'s ``admin_fields`` option) are shown.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/templatetags/leonardo_admin_tags.py#L13-L57
django-leonardo/django-leonardo
leonardo/templatetags/form_helpers.py
add_bootstrap_class
def add_bootstrap_class(field): """Add a "form-control" CSS class to the field's widget. This is so that Bootstrap styles it properly. """ if not isinstance(field.field.widget, ( django.forms.widgets.CheckboxInput, django.forms.widgets.CheckboxSelectMultiple, django.forms.widget...
python
def add_bootstrap_class(field): """Add a "form-control" CSS class to the field's widget. This is so that Bootstrap styles it properly. """ if not isinstance(field.field.widget, ( django.forms.widgets.CheckboxInput, django.forms.widgets.CheckboxSelectMultiple, django.forms.widget...
Add a "form-control" CSS class to the field's widget. This is so that Bootstrap styles it properly.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/templatetags/form_helpers.py#L20-L35