django-nativemojo 0.1.10__py3-none-any.whl → 0.1.16__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- django_nativemojo-0.1.16.dist-info/METADATA +138 -0
- django_nativemojo-0.1.16.dist-info/RECORD +302 -0
- mojo/__init__.py +1 -1
- mojo/apps/account/management/__init__.py +5 -0
- mojo/apps/account/management/commands/__init__.py +6 -0
- mojo/apps/account/management/commands/serializer_admin.py +651 -0
- mojo/apps/account/migrations/0004_user_avatar.py +20 -0
- mojo/apps/account/migrations/0005_group_last_activity.py +18 -0
- mojo/apps/account/migrations/0006_add_device_tracking_models.py +72 -0
- mojo/apps/account/migrations/0007_delete_userdevicelocation.py +16 -0
- mojo/apps/account/migrations/0008_userdevicelocation.py +33 -0
- mojo/apps/account/migrations/0009_geolocatedip_subnet.py +18 -0
- mojo/apps/account/migrations/0010_group_avatar.py +20 -0
- mojo/apps/account/migrations/0011_user_org_registereddevice_pushconfig_and_more.py +118 -0
- mojo/apps/account/migrations/0012_remove_pushconfig_apns_key_file_and_more.py +21 -0
- mojo/apps/account/migrations/0013_pushconfig_test_mode_alter_pushconfig_apns_enabled_and_more.py +28 -0
- mojo/apps/account/migrations/0014_notificationdelivery_data_payload_and_more.py +48 -0
- mojo/apps/account/models/__init__.py +2 -0
- mojo/apps/account/models/device.py +281 -0
- mojo/apps/account/models/group.py +319 -15
- mojo/apps/account/models/member.py +29 -5
- mojo/apps/account/models/push/__init__.py +4 -0
- mojo/apps/account/models/push/config.py +112 -0
- mojo/apps/account/models/push/delivery.py +93 -0
- mojo/apps/account/models/push/device.py +66 -0
- mojo/apps/account/models/push/template.py +99 -0
- mojo/apps/account/models/user.py +369 -19
- mojo/apps/account/rest/__init__.py +2 -0
- mojo/apps/account/rest/device.py +39 -0
- mojo/apps/account/rest/group.py +9 -0
- mojo/apps/account/rest/push.py +187 -0
- mojo/apps/account/rest/user.py +100 -6
- mojo/apps/account/services/__init__.py +1 -0
- mojo/apps/account/services/push.py +363 -0
- mojo/apps/aws/migrations/0001_initial.py +206 -0
- mojo/apps/aws/migrations/0002_emaildomain_can_recv_emaildomain_can_send_and_more.py +28 -0
- mojo/apps/aws/migrations/0003_mailbox_is_domain_default_mailbox_is_system_default_and_more.py +31 -0
- mojo/apps/aws/migrations/0004_s3bucket.py +39 -0
- mojo/apps/aws/migrations/0005_alter_emaildomain_region_delete_s3bucket.py +21 -0
- mojo/apps/aws/models/__init__.py +19 -0
- mojo/apps/aws/models/email_attachment.py +99 -0
- mojo/apps/aws/models/email_domain.py +218 -0
- mojo/apps/aws/models/email_template.py +132 -0
- mojo/apps/aws/models/incoming_email.py +197 -0
- mojo/apps/aws/models/mailbox.py +288 -0
- mojo/apps/aws/models/sent_message.py +175 -0
- mojo/apps/aws/rest/__init__.py +7 -0
- mojo/apps/aws/rest/email.py +33 -0
- mojo/apps/aws/rest/email_ops.py +183 -0
- mojo/apps/aws/rest/messages.py +32 -0
- mojo/apps/aws/rest/s3.py +64 -0
- mojo/apps/aws/rest/send.py +101 -0
- mojo/apps/aws/rest/sns.py +403 -0
- mojo/apps/aws/rest/templates.py +19 -0
- mojo/apps/aws/services/__init__.py +32 -0
- mojo/apps/aws/services/email.py +390 -0
- mojo/apps/aws/services/email_ops.py +548 -0
- mojo/apps/docit/__init__.py +6 -0
- mojo/apps/docit/markdown_plugins/syntax_highlight.py +25 -0
- mojo/apps/docit/markdown_plugins/toc.py +12 -0
- mojo/apps/docit/migrations/0001_initial.py +113 -0
- mojo/apps/docit/migrations/0002_alter_book_modified_by_alter_page_modified_by.py +26 -0
- mojo/apps/docit/migrations/0003_alter_book_group.py +20 -0
- mojo/apps/docit/models/__init__.py +17 -0
- mojo/apps/docit/models/asset.py +231 -0
- mojo/apps/docit/models/book.py +227 -0
- mojo/apps/docit/models/page.py +319 -0
- mojo/apps/docit/models/page_revision.py +203 -0
- mojo/apps/docit/rest/__init__.py +10 -0
- mojo/apps/docit/rest/asset.py +17 -0
- mojo/apps/docit/rest/book.py +22 -0
- mojo/apps/docit/rest/page.py +22 -0
- mojo/apps/docit/rest/page_revision.py +17 -0
- mojo/apps/docit/services/__init__.py +11 -0
- mojo/apps/docit/services/docit.py +315 -0
- mojo/apps/docit/services/markdown.py +44 -0
- mojo/apps/fileman/README.md +8 -8
- mojo/apps/fileman/backends/base.py +76 -70
- mojo/apps/fileman/backends/filesystem.py +86 -86
- mojo/apps/fileman/backends/s3.py +409 -108
- mojo/apps/fileman/migrations/0001_initial.py +106 -0
- mojo/apps/fileman/migrations/0002_filemanager_parent_alter_filemanager_max_file_size.py +24 -0
- mojo/apps/fileman/migrations/0003_remove_file_fileman_fil_upload__c4bc35_idx_and_more.py +25 -0
- mojo/apps/fileman/migrations/0004_remove_file_original_filename_and_more.py +39 -0
- mojo/apps/fileman/migrations/0005_alter_file_upload_token.py +18 -0
- mojo/apps/fileman/migrations/0006_file_download_url_filemanager_forever_urls.py +23 -0
- mojo/apps/fileman/migrations/0007_remove_filemanager_forever_urls_and_more.py +22 -0
- mojo/apps/fileman/migrations/0008_file_category.py +18 -0
- mojo/apps/fileman/migrations/0009_rename_file_path_file_storage_file_path.py +18 -0
- mojo/apps/fileman/migrations/0010_filerendition.py +33 -0
- mojo/apps/fileman/migrations/0011_alter_filerendition_original_file.py +19 -0
- mojo/apps/fileman/models/__init__.py +1 -5
- mojo/apps/fileman/models/file.py +240 -58
- mojo/apps/fileman/models/manager.py +427 -31
- mojo/apps/fileman/models/rendition.py +118 -0
- mojo/apps/fileman/renderer/__init__.py +111 -0
- mojo/apps/fileman/renderer/audio.py +403 -0
- mojo/apps/fileman/renderer/base.py +205 -0
- mojo/apps/fileman/renderer/document.py +404 -0
- mojo/apps/fileman/renderer/image.py +222 -0
- mojo/apps/fileman/renderer/utils.py +297 -0
- mojo/apps/fileman/renderer/video.py +304 -0
- mojo/apps/fileman/rest/__init__.py +1 -18
- mojo/apps/fileman/rest/upload.py +22 -32
- mojo/apps/fileman/signals.py +58 -0
- mojo/apps/fileman/tasks.py +254 -0
- mojo/apps/fileman/utils/__init__.py +40 -16
- mojo/apps/incident/migrations/0005_incidenthistory.py +39 -0
- mojo/apps/incident/migrations/0006_alter_incident_state.py +18 -0
- mojo/apps/incident/migrations/0007_event_uid.py +18 -0
- mojo/apps/incident/migrations/0008_ticket_ticketnote.py +55 -0
- mojo/apps/incident/migrations/0009_incident_status.py +18 -0
- mojo/apps/incident/migrations/0010_event_country_code.py +18 -0
- mojo/apps/incident/migrations/0011_incident_country_code.py +18 -0
- mojo/apps/incident/migrations/0012_alter_incident_status.py +18 -0
- mojo/apps/incident/models/__init__.py +2 -0
- mojo/apps/incident/models/event.py +35 -0
- mojo/apps/incident/models/history.py +36 -0
- mojo/apps/incident/models/incident.py +3 -1
- mojo/apps/incident/models/ticket.py +62 -0
- mojo/apps/incident/reporter.py +21 -1
- mojo/apps/incident/rest/__init__.py +1 -0
- mojo/apps/incident/rest/event.py +7 -1
- mojo/apps/incident/rest/ticket.py +43 -0
- mojo/apps/jobs/__init__.py +489 -0
- mojo/apps/jobs/adapters.py +24 -0
- mojo/apps/jobs/cli.py +616 -0
- mojo/apps/jobs/daemon.py +370 -0
- mojo/apps/jobs/examples/sample_jobs.py +376 -0
- mojo/apps/jobs/examples/webhook_examples.py +203 -0
- mojo/apps/jobs/handlers/__init__.py +5 -0
- mojo/apps/jobs/handlers/webhook.py +317 -0
- mojo/apps/jobs/job_engine.py +734 -0
- mojo/apps/jobs/keys.py +203 -0
- mojo/apps/jobs/local_queue.py +363 -0
- mojo/apps/jobs/management/__init__.py +3 -0
- mojo/apps/jobs/management/commands/__init__.py +3 -0
- mojo/apps/jobs/manager.py +1327 -0
- mojo/apps/jobs/migrations/0001_initial.py +97 -0
- mojo/apps/jobs/migrations/0002_alter_job_max_retries_joblog.py +39 -0
- mojo/apps/jobs/models/__init__.py +6 -0
- mojo/apps/jobs/models/job.py +441 -0
- mojo/apps/jobs/rest/__init__.py +2 -0
- mojo/apps/jobs/rest/control.py +466 -0
- mojo/apps/jobs/rest/jobs.py +421 -0
- mojo/apps/jobs/scheduler.py +571 -0
- mojo/apps/jobs/services/__init__.py +6 -0
- mojo/apps/jobs/services/job_actions.py +465 -0
- mojo/apps/jobs/settings.py +209 -0
- mojo/apps/logit/migrations/0004_alter_log_level.py +18 -0
- mojo/apps/logit/models/log.py +7 -1
- mojo/apps/metrics/__init__.py +8 -1
- mojo/apps/metrics/redis_metrics.py +198 -0
- mojo/apps/metrics/rest/__init__.py +3 -0
- mojo/apps/metrics/rest/categories.py +266 -0
- mojo/apps/metrics/rest/helpers.py +48 -0
- mojo/apps/metrics/rest/permissions.py +99 -0
- mojo/apps/metrics/rest/values.py +277 -0
- mojo/apps/metrics/utils.py +19 -2
- mojo/decorators/auth.py +6 -1
- mojo/decorators/http.py +47 -3
- mojo/helpers/aws/__init__.py +45 -0
- mojo/helpers/aws/ec2.py +804 -0
- mojo/helpers/aws/iam.py +748 -0
- mojo/helpers/aws/inbound_email.py +309 -0
- mojo/helpers/aws/kms.py +413 -0
- mojo/helpers/aws/s3.py +451 -11
- mojo/helpers/aws/ses.py +483 -0
- mojo/helpers/aws/ses_domain.py +959 -0
- mojo/helpers/aws/sns.py +461 -0
- mojo/helpers/crypto/__init__.py +1 -1
- mojo/helpers/crypto/utils.py +15 -0
- mojo/helpers/dates.py +18 -0
- mojo/helpers/location/__init__.py +2 -0
- mojo/helpers/location/countries.py +262 -0
- mojo/helpers/location/geolocation.py +196 -0
- mojo/helpers/logit.py +37 -0
- mojo/helpers/redis/__init__.py +2 -0
- mojo/helpers/redis/adapter.py +606 -0
- mojo/helpers/redis/client.py +48 -0
- mojo/helpers/redis/pool.py +225 -0
- mojo/helpers/request.py +8 -0
- mojo/helpers/response.py +14 -2
- mojo/helpers/settings/__init__.py +2 -0
- mojo/helpers/{settings.py → settings/helper.py} +1 -37
- mojo/helpers/settings/parser.py +132 -0
- mojo/middleware/auth.py +1 -1
- mojo/middleware/cors.py +40 -0
- mojo/middleware/logging.py +131 -12
- mojo/middleware/mojo.py +10 -0
- mojo/models/rest.py +494 -65
- mojo/models/secrets.py +98 -3
- mojo/serializers/__init__.py +106 -0
- mojo/serializers/core/__init__.py +90 -0
- mojo/serializers/core/cache/__init__.py +121 -0
- mojo/serializers/core/cache/backends.py +518 -0
- mojo/serializers/core/cache/base.py +102 -0
- mojo/serializers/core/cache/disabled.py +181 -0
- mojo/serializers/core/cache/memory.py +287 -0
- mojo/serializers/core/cache/redis.py +533 -0
- mojo/serializers/core/cache/utils.py +454 -0
- mojo/serializers/core/manager.py +550 -0
- mojo/serializers/core/serializer.py +475 -0
- mojo/serializers/examples/settings.py +322 -0
- mojo/serializers/formats/csv.py +393 -0
- mojo/serializers/formats/localizers.py +509 -0
- mojo/serializers/{models.py → simple.py} +38 -15
- mojo/serializers/suggested_improvements.md +388 -0
- testit/client.py +1 -1
- testit/helpers.py +35 -4
- testit/runner.py +23 -6
- django_nativemojo-0.1.10.dist-info/METADATA +0 -96
- django_nativemojo-0.1.10.dist-info/RECORD +0 -194
- mojo/apps/metrics/rest/db.py +0 -0
- mojo/apps/notify/README.md +0 -91
- mojo/apps/notify/README_NOTIFICATIONS.md +0 -566
- mojo/apps/notify/admin.py +0 -52
- mojo/apps/notify/handlers/example_handlers.py +0 -516
- mojo/apps/notify/handlers/ses/__init__.py +0 -25
- mojo/apps/notify/handlers/ses/bounce.py +0 -0
- mojo/apps/notify/handlers/ses/complaint.py +0 -25
- mojo/apps/notify/handlers/ses/message.py +0 -86
- mojo/apps/notify/management/commands/__init__.py +0 -1
- mojo/apps/notify/management/commands/process_notifications.py +0 -370
- mojo/apps/notify/mod +0 -0
- mojo/apps/notify/models/__init__.py +0 -12
- mojo/apps/notify/models/account.py +0 -128
- mojo/apps/notify/models/attachment.py +0 -24
- mojo/apps/notify/models/bounce.py +0 -68
- mojo/apps/notify/models/complaint.py +0 -40
- mojo/apps/notify/models/inbox.py +0 -113
- mojo/apps/notify/models/inbox_message.py +0 -173
- mojo/apps/notify/models/outbox.py +0 -129
- mojo/apps/notify/models/outbox_message.py +0 -288
- mojo/apps/notify/models/template.py +0 -30
- mojo/apps/notify/providers/aws.py +0 -73
- mojo/apps/notify/rest/ses.py +0 -0
- mojo/apps/notify/utils/__init__.py +0 -2
- mojo/apps/notify/utils/notifications.py +0 -404
- mojo/apps/notify/utils/parsing.py +0 -202
- mojo/apps/notify/utils/render.py +0 -144
- mojo/apps/tasks/README.md +0 -118
- mojo/apps/tasks/__init__.py +0 -11
- mojo/apps/tasks/manager.py +0 -489
- mojo/apps/tasks/rest/__init__.py +0 -2
- mojo/apps/tasks/rest/hooks.py +0 -0
- mojo/apps/tasks/rest/tasks.py +0 -62
- mojo/apps/tasks/runner.py +0 -174
- mojo/apps/tasks/tq_handlers.py +0 -14
- mojo/helpers/aws/setup_email.py +0 -0
- mojo/helpers/redis.py +0 -10
- mojo/models/meta.py +0 -262
- mojo/ws4redis/README.md +0 -174
- mojo/ws4redis/__init__.py +0 -2
- mojo/ws4redis/client.py +0 -283
- mojo/ws4redis/connection.py +0 -327
- mojo/ws4redis/exceptions.py +0 -32
- mojo/ws4redis/redis.py +0 -183
- mojo/ws4redis/servers/base.py +0 -86
- mojo/ws4redis/servers/django.py +0 -171
- mojo/ws4redis/servers/uwsgi.py +0 -63
- mojo/ws4redis/settings.py +0 -45
- mojo/ws4redis/utf8validator.py +0 -128
- mojo/ws4redis/websocket.py +0 -403
- {django_nativemojo-0.1.10.dist-info → django_nativemojo-0.1.16.dist-info}/LICENSE +0 -0
- {django_nativemojo-0.1.10.dist-info → django_nativemojo-0.1.16.dist-info}/NOTICE +0 -0
- {django_nativemojo-0.1.10.dist-info → django_nativemojo-0.1.16.dist-info}/WHEEL +0 -0
- /mojo/apps/{notify → aws}/__init__.py +0 -0
- /mojo/apps/{notify/handlers → aws/migrations}/__init__.py +0 -0
- /mojo/apps/{notify/management → docit/markdown_plugins}/__init__.py +0 -0
- /mojo/apps/{notify/providers → docit/migrations}/__init__.py +0 -0
- /mojo/apps/{notify/rest → fileman/migrations}/__init__.py +0 -0
- /mojo/{ws4redis/servers → apps/jobs/examples}/__init__.py +0 -0
- /mojo/apps/{fileman/models/render.py → jobs/migrations/__init__.py} +0 -0
- /mojo/{serializers → rest}/openapi.py +0 -0
- /mojo/{apps/fileman/rest/__init__ → serializers/formats/__init__.py} +0 -0
@@ -0,0 +1,322 @@
|
|
1
|
+
"""
|
2
|
+
Django-MOJO Serializer Settings Configuration Examples
|
3
|
+
|
4
|
+
This file demonstrates how to configure the MOJO serializer system through Django settings.
|
5
|
+
Add the desired configurations to your project's settings.py file.
|
6
|
+
|
7
|
+
The serializer system supports:
|
8
|
+
- Multiple serializer backends (simple, optimized, advanced, custom)
|
9
|
+
- Performance tuning and caching configuration
|
10
|
+
- Runtime serializer switching
|
11
|
+
- Custom serializer registration
|
12
|
+
- Monitoring and debugging options
|
13
|
+
"""
|
14
|
+
|
15
|
+
# =============================================================================
|
16
|
+
# BASIC SERIALIZER CONFIGURATION
|
17
|
+
# =============================================================================
|
18
|
+
|
19
|
+
# Default serializer to use throughout the application
|
20
|
+
# Options: 'simple', 'optimized', 'advanced', or any custom registered name
|
21
|
+
MOJO_DEFAULT_SERIALIZER = 'optimized'
|
22
|
+
|
23
|
+
# Enable/disable performance tracking for serializers
|
24
|
+
MOJO_SERIALIZER_PERFORMANCE_TRACKING = True
|
25
|
+
|
26
|
+
# Enable debug logging for serializer operations
|
27
|
+
MOJO_SERIALIZER_DEBUG = False
|
28
|
+
|
29
|
+
# =============================================================================
|
30
|
+
# CUSTOM SERIALIZER REGISTRATION
|
31
|
+
# =============================================================================
|
32
|
+
|
33
|
+
# Register custom serializers
|
34
|
+
# Format: {'name': 'import.path.to.SerializerClass'} or {'name': config_dict}
|
35
|
+
MOJO_CUSTOM_SERIALIZERS = {
|
36
|
+
# Simple string path registration
|
37
|
+
'my_custom': 'myapp.serializers.CustomGraphSerializer',
|
38
|
+
|
39
|
+
# Detailed configuration with metadata
|
40
|
+
'enterprise': {
|
41
|
+
'class': 'myapp.serializers.EnterpriseSerializer',
|
42
|
+
'description': 'Enterprise-grade serializer with audit logging',
|
43
|
+
'is_default': False
|
44
|
+
},
|
45
|
+
|
46
|
+
# Redis-backed caching serializer
|
47
|
+
'redis_cached': {
|
48
|
+
'class': 'myapp.serializers.RedisCachedSerializer',
|
49
|
+
'description': 'Serializer with Redis-based distributed caching',
|
50
|
+
'is_default': False
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
# =============================================================================
|
55
|
+
# PERFORMANCE AND CACHING CONFIGURATION
|
56
|
+
# =============================================================================
|
57
|
+
|
58
|
+
# Optimized serializer cache settings
|
59
|
+
MOJO_OPTIMIZED_SERIALIZER = {
|
60
|
+
# Instance cache settings (model+graph+pk -> serialized data)
|
61
|
+
'instance_cache_size': 5000, # Maximum cached instances
|
62
|
+
'instance_cache_ttl': 300, # Time-to-live in seconds (5 minutes)
|
63
|
+
|
64
|
+
# Graph configuration cache (model+graph -> compiled config)
|
65
|
+
'graph_cache_size': 500, # Maximum cached graph configs
|
66
|
+
'graph_cache_ttl': 600, # Time-to-live in seconds (10 minutes)
|
67
|
+
|
68
|
+
# Query optimization cache
|
69
|
+
'query_cache_size': 500, # Maximum cached query optimizations
|
70
|
+
'query_cache_ttl': 600, # Time-to-live in seconds (10 minutes)
|
71
|
+
|
72
|
+
# Performance monitoring
|
73
|
+
'enable_performance_stats': True, # Track performance metrics
|
74
|
+
'stats_history_size': 1000, # Number of operations to track
|
75
|
+
}
|
76
|
+
|
77
|
+
# Advanced serializer settings (if using advanced serializer)
|
78
|
+
MOJO_ADVANCED_SERIALIZER = {
|
79
|
+
# Multi-format support
|
80
|
+
'enable_csv_export': True,
|
81
|
+
'enable_excel_export': True,
|
82
|
+
'enable_html_debug': True,
|
83
|
+
|
84
|
+
# Excel export settings
|
85
|
+
'excel_max_rows': 100000, # Maximum rows for Excel export
|
86
|
+
'excel_auto_width': True, # Auto-adjust column widths
|
87
|
+
'excel_freeze_panes': True, # Freeze header row
|
88
|
+
|
89
|
+
# CSV export settings
|
90
|
+
'csv_streaming_threshold': 1000, # Use streaming for > N rows
|
91
|
+
'csv_delimiter': ',', # CSV field delimiter
|
92
|
+
'csv_encoding': 'utf-8', # CSV file encoding
|
93
|
+
|
94
|
+
# Performance settings
|
95
|
+
'enable_caching': True,
|
96
|
+
'cache_timeout': 300, # Cache timeout in seconds
|
97
|
+
}
|
98
|
+
|
99
|
+
# =============================================================================
|
100
|
+
# DEVELOPMENT AND DEBUGGING
|
101
|
+
# =============================================================================
|
102
|
+
|
103
|
+
# Development-specific settings
|
104
|
+
if DEBUG:
|
105
|
+
# Enable detailed logging in development
|
106
|
+
MOJO_SERIALIZER_DEBUG = True
|
107
|
+
|
108
|
+
# Use smaller cache sizes for development
|
109
|
+
MOJO_OPTIMIZED_SERIALIZER['instance_cache_size'] = 1000
|
110
|
+
MOJO_OPTIMIZED_SERIALIZER['graph_cache_size'] = 100
|
111
|
+
|
112
|
+
# Enable performance benchmarking
|
113
|
+
MOJO_ENABLE_SERIALIZER_BENCHMARKS = True
|
114
|
+
|
115
|
+
# Production optimizations
|
116
|
+
else:
|
117
|
+
# Disable debug logging in production
|
118
|
+
MOJO_SERIALIZER_DEBUG = False
|
119
|
+
|
120
|
+
# Increase cache sizes for production
|
121
|
+
MOJO_OPTIMIZED_SERIALIZER['instance_cache_size'] = 10000
|
122
|
+
MOJO_OPTIMIZED_SERIALIZER['graph_cache_size'] = 1000
|
123
|
+
|
124
|
+
# Disable benchmarking in production
|
125
|
+
MOJO_ENABLE_SERIALIZER_BENCHMARKS = False
|
126
|
+
|
127
|
+
# =============================================================================
|
128
|
+
# REDIS INTEGRATION (Optional)
|
129
|
+
# =============================================================================
|
130
|
+
|
131
|
+
# Redis-backed caching for distributed environments
|
132
|
+
MOJO_REDIS_SERIALIZER_CACHE = {
|
133
|
+
'enabled': False, # Enable Redis caching
|
134
|
+
'host': 'localhost',
|
135
|
+
'port': 6379,
|
136
|
+
'db': 2, # Use separate DB for serializer cache
|
137
|
+
'password': None,
|
138
|
+
'key_prefix': 'mojo:serializer:', # Cache key prefix
|
139
|
+
'default_timeout': 300, # Default cache timeout
|
140
|
+
'connection_pool_kwargs': {
|
141
|
+
'max_connections': 50
|
142
|
+
}
|
143
|
+
}
|
144
|
+
|
145
|
+
# =============================================================================
|
146
|
+
# MONITORING AND ALERTS
|
147
|
+
# =============================================================================
|
148
|
+
|
149
|
+
# Performance monitoring thresholds
|
150
|
+
MOJO_SERIALIZER_MONITORING = {
|
151
|
+
'slow_serialization_threshold': 1.0, # Log if serialization takes > 1 second
|
152
|
+
'memory_usage_threshold': 100 * 1024 * 1024, # Alert if using > 100MB memory
|
153
|
+
'cache_hit_rate_threshold': 0.80, # Alert if cache hit rate < 80%
|
154
|
+
'error_rate_threshold': 0.05, # Alert if error rate > 5%
|
155
|
+
}
|
156
|
+
|
157
|
+
# Integration with external monitoring systems
|
158
|
+
MOJO_EXTERNAL_MONITORING = {
|
159
|
+
# StatsD integration
|
160
|
+
'statsd': {
|
161
|
+
'enabled': False,
|
162
|
+
'host': 'localhost',
|
163
|
+
'port': 8125,
|
164
|
+
'prefix': 'mojo.serializer'
|
165
|
+
},
|
166
|
+
|
167
|
+
# Sentry integration for error tracking
|
168
|
+
'sentry': {
|
169
|
+
'enabled': False,
|
170
|
+
'track_performance': True,
|
171
|
+
'sample_rate': 0.1 # Sample 10% of operations
|
172
|
+
}
|
173
|
+
}
|
174
|
+
|
175
|
+
# =============================================================================
|
176
|
+
# FEATURE FLAGS
|
177
|
+
# =============================================================================
|
178
|
+
|
179
|
+
# Feature flags for gradual rollout of new serializer features
|
180
|
+
MOJO_SERIALIZER_FEATURES = {
|
181
|
+
'optimized_serializer_default': True, # Use optimized serializer by default
|
182
|
+
'automatic_query_optimization': True, # Enable automatic select_related/prefetch_related
|
183
|
+
'advanced_caching': True, # Enable advanced caching strategies
|
184
|
+
'performance_monitoring': True, # Enable detailed performance monitoring
|
185
|
+
'async_serialization': False, # Enable async serialization (experimental)
|
186
|
+
'distributed_caching': False, # Enable distributed caching (experimental)
|
187
|
+
}
|
188
|
+
|
189
|
+
# =============================================================================
|
190
|
+
# MODEL-SPECIFIC CONFIGURATIONS
|
191
|
+
# =============================================================================
|
192
|
+
|
193
|
+
# Override serializer settings for specific models
|
194
|
+
MOJO_MODEL_SERIALIZER_OVERRIDES = {
|
195
|
+
'auth.User': {
|
196
|
+
'default_serializer': 'simple', # Use simple serializer for User model
|
197
|
+
'cache_ttl': 60, # Shorter cache TTL for user data
|
198
|
+
'enable_caching': True
|
199
|
+
},
|
200
|
+
|
201
|
+
'myapp.LargeDataModel': {
|
202
|
+
'default_serializer': 'optimized', # Use optimized serializer for large models
|
203
|
+
'cache_ttl': 1800, # Longer cache TTL for stable data
|
204
|
+
'enable_query_optimization': True
|
205
|
+
},
|
206
|
+
|
207
|
+
'reports.AnalyticsData': {
|
208
|
+
'default_serializer': 'advanced', # Use advanced serializer for reports
|
209
|
+
'enable_csv_export': True,
|
210
|
+
'enable_excel_export': True
|
211
|
+
}
|
212
|
+
}
|
213
|
+
|
214
|
+
# =============================================================================
|
215
|
+
# LOGGING CONFIGURATION
|
216
|
+
# =============================================================================
|
217
|
+
|
218
|
+
# Add serializer-specific logging configuration to Django's LOGGING setting
|
219
|
+
SERIALIZER_LOGGING = {
|
220
|
+
'version': 1,
|
221
|
+
'disable_existing_loggers': False,
|
222
|
+
'formatters': {
|
223
|
+
'serializer': {
|
224
|
+
'format': '[{levelname}] {asctime} {name} - {message}',
|
225
|
+
'style': '{',
|
226
|
+
},
|
227
|
+
},
|
228
|
+
'handlers': {
|
229
|
+
'serializer_file': {
|
230
|
+
'level': 'INFO',
|
231
|
+
'class': 'logging.handlers.RotatingFileHandler',
|
232
|
+
'filename': 'logs/serializer.log',
|
233
|
+
'maxBytes': 10 * 1024 * 1024, # 10MB
|
234
|
+
'backupCount': 5,
|
235
|
+
'formatter': 'serializer',
|
236
|
+
},
|
237
|
+
'performance_file': {
|
238
|
+
'level': 'INFO',
|
239
|
+
'class': 'logging.handlers.RotatingFileHandler',
|
240
|
+
'filename': 'logs/serializer_performance.log',
|
241
|
+
'maxBytes': 10 * 1024 * 1024, # 10MB
|
242
|
+
'backupCount': 3,
|
243
|
+
'formatter': 'serializer',
|
244
|
+
},
|
245
|
+
},
|
246
|
+
'loggers': {
|
247
|
+
'optimized_serializer': {
|
248
|
+
'handlers': ['serializer_file'],
|
249
|
+
'level': 'INFO',
|
250
|
+
'propagate': True,
|
251
|
+
},
|
252
|
+
'serializer_manager': {
|
253
|
+
'handlers': ['serializer_file'],
|
254
|
+
'level': 'INFO',
|
255
|
+
'propagate': True,
|
256
|
+
},
|
257
|
+
'serializer_performance': {
|
258
|
+
'handlers': ['performance_file'],
|
259
|
+
'level': 'INFO',
|
260
|
+
'propagate': False,
|
261
|
+
},
|
262
|
+
},
|
263
|
+
}
|
264
|
+
|
265
|
+
# Merge serializer logging into main LOGGING configuration
|
266
|
+
# Note: In your actual settings.py, you would merge this into your existing LOGGING dict
|
267
|
+
|
268
|
+
# =============================================================================
|
269
|
+
# MIGRATION AND COMPATIBILITY
|
270
|
+
# =============================================================================
|
271
|
+
|
272
|
+
# Backwards compatibility settings
|
273
|
+
MOJO_SERIALIZER_COMPATIBILITY = {
|
274
|
+
# Support legacy GraphSerializer API
|
275
|
+
'legacy_graph_serializer_support': True,
|
276
|
+
|
277
|
+
# Automatically migrate from simple to optimized serializer
|
278
|
+
'auto_migrate_simple_to_optimized': True,
|
279
|
+
|
280
|
+
# Warn about deprecated serializer features
|
281
|
+
'deprecation_warnings': True,
|
282
|
+
|
283
|
+
# Fallback to simple serializer on errors
|
284
|
+
'fallback_on_errors': True
|
285
|
+
}
|
286
|
+
|
287
|
+
# =============================================================================
|
288
|
+
# EXAMPLE USAGE IN VIEWS/MODELS
|
289
|
+
# =============================================================================
|
290
|
+
|
291
|
+
"""
|
292
|
+
Example usage in your Django code:
|
293
|
+
|
294
|
+
# In views.py
|
295
|
+
from mojo.serializers import serialize, to_response
|
296
|
+
|
297
|
+
def my_api_view(request):
|
298
|
+
queryset = MyModel.objects.all()
|
299
|
+
|
300
|
+
# Use default configured serializer
|
301
|
+
return to_response(queryset, request, graph="list")
|
302
|
+
|
303
|
+
# Force specific serializer
|
304
|
+
return to_response(queryset, request, graph="list", serializer_type="optimized")
|
305
|
+
|
306
|
+
# In models.py
|
307
|
+
class MyModel(MojoModel):
|
308
|
+
name = models.CharField(max_length=100)
|
309
|
+
|
310
|
+
class RestMeta:
|
311
|
+
GRAPHS = {
|
312
|
+
"default": {"fields": ["id", "name"]},
|
313
|
+
"list": {"fields": ["id", "name"]},
|
314
|
+
"detail": {"fields": ["id", "name", "created", "modified"]}
|
315
|
+
}
|
316
|
+
|
317
|
+
# Management commands
|
318
|
+
# python manage.py serializer_admin list
|
319
|
+
# python manage.py serializer_admin benchmark --model MyModel --count 1000
|
320
|
+
# python manage.py serializer_admin stats
|
321
|
+
# python manage.py serializer_admin clear-cache
|
322
|
+
"""
|