wappa 0.1.9__py3-none-any.whl โ†’ 0.1.10__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.

Potentially problematic release.


This version of wappa might be problematic. Click here for more details.

Files changed (126) hide show
  1. wappa/__init__.py +4 -5
  2. wappa/api/controllers/webhook_controller.py +5 -2
  3. wappa/api/dependencies/__init__.py +0 -5
  4. wappa/api/middleware/error_handler.py +4 -4
  5. wappa/api/middleware/owner.py +11 -5
  6. wappa/api/routes/webhooks.py +2 -2
  7. wappa/cli/__init__.py +1 -1
  8. wappa/cli/examples/init/app/main.py +2 -1
  9. wappa/cli/examples/init/app/master_event.py +5 -3
  10. wappa/cli/examples/json_cache_example/app/__init__.py +1 -1
  11. wappa/cli/examples/json_cache_example/app/main.py +56 -44
  12. wappa/cli/examples/json_cache_example/app/master_event.py +181 -145
  13. wappa/cli/examples/json_cache_example/app/models/__init__.py +1 -1
  14. wappa/cli/examples/json_cache_example/app/models/json_demo_models.py +32 -51
  15. wappa/cli/examples/json_cache_example/app/scores/__init__.py +2 -2
  16. wappa/cli/examples/json_cache_example/app/scores/score_base.py +52 -46
  17. wappa/cli/examples/json_cache_example/app/scores/score_cache_statistics.py +70 -62
  18. wappa/cli/examples/json_cache_example/app/scores/score_message_history.py +41 -44
  19. wappa/cli/examples/json_cache_example/app/scores/score_state_commands.py +83 -71
  20. wappa/cli/examples/json_cache_example/app/scores/score_user_management.py +73 -57
  21. wappa/cli/examples/json_cache_example/app/utils/__init__.py +2 -2
  22. wappa/cli/examples/json_cache_example/app/utils/cache_utils.py +54 -56
  23. wappa/cli/examples/json_cache_example/app/utils/message_utils.py +85 -80
  24. wappa/cli/examples/openai_transcript/app/main.py +2 -1
  25. wappa/cli/examples/openai_transcript/app/master_event.py +31 -22
  26. wappa/cli/examples/openai_transcript/app/openai_utils/__init__.py +1 -1
  27. wappa/cli/examples/openai_transcript/app/openai_utils/audio_processing.py +37 -24
  28. wappa/cli/examples/redis_cache_example/app/__init__.py +1 -1
  29. wappa/cli/examples/redis_cache_example/app/main.py +56 -44
  30. wappa/cli/examples/redis_cache_example/app/master_event.py +181 -145
  31. wappa/cli/examples/redis_cache_example/app/models/redis_demo_models.py +31 -50
  32. wappa/cli/examples/redis_cache_example/app/scores/__init__.py +2 -2
  33. wappa/cli/examples/redis_cache_example/app/scores/score_base.py +52 -46
  34. wappa/cli/examples/redis_cache_example/app/scores/score_cache_statistics.py +70 -62
  35. wappa/cli/examples/redis_cache_example/app/scores/score_message_history.py +41 -44
  36. wappa/cli/examples/redis_cache_example/app/scores/score_state_commands.py +83 -71
  37. wappa/cli/examples/redis_cache_example/app/scores/score_user_management.py +73 -57
  38. wappa/cli/examples/redis_cache_example/app/utils/__init__.py +2 -2
  39. wappa/cli/examples/redis_cache_example/app/utils/cache_utils.py +54 -56
  40. wappa/cli/examples/redis_cache_example/app/utils/message_utils.py +85 -80
  41. wappa/cli/examples/simple_echo_example/app/__init__.py +1 -1
  42. wappa/cli/examples/simple_echo_example/app/main.py +41 -33
  43. wappa/cli/examples/simple_echo_example/app/master_event.py +78 -57
  44. wappa/cli/examples/wappa_full_example/app/__init__.py +1 -1
  45. wappa/cli/examples/wappa_full_example/app/handlers/__init__.py +1 -1
  46. wappa/cli/examples/wappa_full_example/app/handlers/command_handlers.py +134 -126
  47. wappa/cli/examples/wappa_full_example/app/handlers/message_handlers.py +237 -229
  48. wappa/cli/examples/wappa_full_example/app/handlers/state_handlers.py +170 -148
  49. wappa/cli/examples/wappa_full_example/app/main.py +51 -39
  50. wappa/cli/examples/wappa_full_example/app/master_event.py +179 -120
  51. wappa/cli/examples/wappa_full_example/app/models/__init__.py +1 -1
  52. wappa/cli/examples/wappa_full_example/app/models/state_models.py +113 -104
  53. wappa/cli/examples/wappa_full_example/app/models/user_models.py +92 -76
  54. wappa/cli/examples/wappa_full_example/app/models/webhook_metadata.py +109 -83
  55. wappa/cli/examples/wappa_full_example/app/utils/__init__.py +1 -1
  56. wappa/cli/examples/wappa_full_example/app/utils/cache_utils.py +132 -113
  57. wappa/cli/examples/wappa_full_example/app/utils/media_handler.py +175 -132
  58. wappa/cli/examples/wappa_full_example/app/utils/metadata_extractor.py +126 -87
  59. wappa/cli/main.py +9 -4
  60. wappa/core/__init__.py +18 -23
  61. wappa/core/config/settings.py +7 -5
  62. wappa/core/events/default_handlers.py +1 -1
  63. wappa/core/factory/wappa_builder.py +38 -25
  64. wappa/core/plugins/redis_plugin.py +1 -3
  65. wappa/core/plugins/wappa_core_plugin.py +7 -6
  66. wappa/core/types.py +12 -12
  67. wappa/core/wappa_app.py +10 -8
  68. wappa/database/__init__.py +3 -4
  69. wappa/domain/enums/messenger_platform.py +1 -2
  70. wappa/domain/factories/media_factory.py +5 -20
  71. wappa/domain/factories/message_factory.py +5 -20
  72. wappa/domain/factories/messenger_factory.py +2 -4
  73. wappa/domain/interfaces/cache_interface.py +7 -7
  74. wappa/domain/interfaces/media_interface.py +2 -5
  75. wappa/domain/models/media_result.py +1 -3
  76. wappa/domain/models/platforms/platform_config.py +1 -3
  77. wappa/messaging/__init__.py +9 -12
  78. wappa/messaging/whatsapp/handlers/whatsapp_media_handler.py +20 -22
  79. wappa/models/__init__.py +27 -35
  80. wappa/persistence/__init__.py +12 -15
  81. wappa/persistence/cache_factory.py +0 -1
  82. wappa/persistence/json/__init__.py +1 -1
  83. wappa/persistence/json/cache_adapters.py +37 -25
  84. wappa/persistence/json/handlers/state_handler.py +60 -52
  85. wappa/persistence/json/handlers/table_handler.py +51 -49
  86. wappa/persistence/json/handlers/user_handler.py +71 -55
  87. wappa/persistence/json/handlers/utils/file_manager.py +42 -39
  88. wappa/persistence/json/handlers/utils/key_factory.py +1 -1
  89. wappa/persistence/json/handlers/utils/serialization.py +13 -11
  90. wappa/persistence/json/json_cache_factory.py +4 -8
  91. wappa/persistence/json/storage_manager.py +66 -79
  92. wappa/persistence/memory/__init__.py +1 -1
  93. wappa/persistence/memory/cache_adapters.py +37 -25
  94. wappa/persistence/memory/handlers/state_handler.py +62 -52
  95. wappa/persistence/memory/handlers/table_handler.py +59 -53
  96. wappa/persistence/memory/handlers/user_handler.py +75 -55
  97. wappa/persistence/memory/handlers/utils/key_factory.py +1 -1
  98. wappa/persistence/memory/handlers/utils/memory_store.py +75 -71
  99. wappa/persistence/memory/handlers/utils/ttl_manager.py +59 -67
  100. wappa/persistence/memory/memory_cache_factory.py +3 -7
  101. wappa/persistence/memory/storage_manager.py +52 -62
  102. wappa/persistence/redis/cache_adapters.py +27 -21
  103. wappa/persistence/redis/ops.py +11 -11
  104. wappa/persistence/redis/redis_client.py +4 -6
  105. wappa/persistence/redis/redis_manager.py +12 -4
  106. wappa/processors/factory.py +5 -5
  107. wappa/schemas/factory.py +2 -5
  108. wappa/schemas/whatsapp/message_types/errors.py +3 -12
  109. wappa/schemas/whatsapp/validators.py +3 -3
  110. wappa/webhooks/__init__.py +17 -18
  111. wappa/webhooks/factory.py +3 -5
  112. wappa/webhooks/whatsapp/__init__.py +10 -13
  113. wappa/webhooks/whatsapp/message_types/audio.py +0 -4
  114. wappa/webhooks/whatsapp/message_types/document.py +1 -9
  115. wappa/webhooks/whatsapp/message_types/errors.py +3 -12
  116. wappa/webhooks/whatsapp/message_types/location.py +1 -21
  117. wappa/webhooks/whatsapp/message_types/sticker.py +1 -5
  118. wappa/webhooks/whatsapp/message_types/text.py +0 -6
  119. wappa/webhooks/whatsapp/message_types/video.py +1 -20
  120. wappa/webhooks/whatsapp/status_models.py +2 -2
  121. wappa/webhooks/whatsapp/validators.py +3 -3
  122. {wappa-0.1.9.dist-info โ†’ wappa-0.1.10.dist-info}/METADATA +362 -8
  123. {wappa-0.1.9.dist-info โ†’ wappa-0.1.10.dist-info}/RECORD +126 -126
  124. {wappa-0.1.9.dist-info โ†’ wappa-0.1.10.dist-info}/WHEEL +0 -0
  125. {wappa-0.1.9.dist-info โ†’ wappa-0.1.10.dist-info}/entry_points.txt +0 -0
  126. {wappa-0.1.9.dist-info โ†’ wappa-0.1.10.dist-info}/licenses/LICENSE +0 -0
wappa/__init__.py CHANGED
@@ -11,19 +11,18 @@ Clean Import Interface (SRP Compliance):
11
11
  """
12
12
 
13
13
  # Framework Essentials Only (SRP: Framework Foundation)
14
- from .core.wappa_app import Wappa
15
- from .core.events.event_handler import WappaEventHandler
16
- from .core.factory import WappaBuilder, WappaPlugin
17
-
18
14
  # Dynamic version from pyproject.toml
19
15
  from .core.config.settings import settings
16
+ from .core.events.event_handler import WappaEventHandler
17
+ from .core.factory import WappaBuilder, WappaPlugin
18
+ from .core.wappa_app import Wappa
20
19
 
21
20
  __version__ = settings.version
22
21
 
23
22
  __all__ = [
24
23
  # Core Framework Components
25
24
  "Wappa",
26
- "WappaEventHandler",
25
+ "WappaEventHandler",
27
26
  "WappaBuilder",
28
27
  "WappaPlugin",
29
28
  ]
@@ -144,8 +144,9 @@ class WebhookController:
144
144
 
145
145
  # ENHANCED DEBUGGING: Show context details
146
146
  from wappa.core.logging.context import get_context_info
147
+
147
148
  context_info = get_context_info()
148
-
149
+
149
150
  self.logger.debug(
150
151
  f"Processing webhook for platform: {platform}, owner: {owner_id}"
151
152
  )
@@ -395,7 +396,9 @@ class WebhookController:
395
396
  factory_class = create_cache_factory(cache_type)
396
397
  cache_factory = factory_class(tenant_id=tenant_id, user_id=user_id)
397
398
 
398
- self.logger.debug(f"โœ… Created {cache_factory.__class__.__name__} successfully")
399
+ self.logger.debug(
400
+ f"โœ… Created {cache_factory.__class__.__name__} successfully"
401
+ )
399
402
  return cache_factory
400
403
 
401
404
  except Exception as e:
@@ -5,11 +5,6 @@ Provides reusable dependencies for controllers, services, and middleware
5
5
  following clean architecture patterns.
6
6
  """
7
7
 
8
- from functools import lru_cache
9
- from typing import Annotated
10
-
11
- from fastapi import Depends, HTTPException, Request
12
-
13
8
  # Import existing dependencies
14
9
  from .whatsapp_dependencies import *
15
10
  from .whatsapp_media_dependencies import *
@@ -40,11 +40,11 @@ class ErrorHandlerMiddleware(BaseHTTPMiddleware):
40
40
 
41
41
  async def _log_http_exception(self, request: Request, exc: HTTPException) -> None:
42
42
  """Log HTTP exceptions with tenant context."""
43
- tenant_id = getattr(request.state, "tenant_id", "unknown")
43
+ getattr(request.state, "tenant_id", "unknown")
44
44
  logger = get_logger(__name__)
45
45
 
46
46
  # Extract user context from request if available
47
- user_id = getattr(request.state, "user_id", "unknown")
47
+ getattr(request.state, "user_id", "unknown")
48
48
 
49
49
  logger.warning(
50
50
  f"HTTP {exc.status_code} - {request.method} {request.url.path} - "
@@ -55,8 +55,8 @@ class ErrorHandlerMiddleware(BaseHTTPMiddleware):
55
55
  self, request: Request, exc: Exception
56
56
  ) -> JSONResponse:
57
57
  """Handle unexpected exceptions with proper logging and response."""
58
- tenant_id = getattr(request.state, "tenant_id", "unknown")
59
- user_id = getattr(request.state, "user_id", "unknown")
58
+ getattr(request.state, "tenant_id", "unknown")
59
+ getattr(request.state, "user_id", "unknown")
60
60
 
61
61
  # Get context-aware logger
62
62
  logger = get_logger(__name__)
@@ -32,14 +32,16 @@ class OwnerMiddleware(BaseHTTPMiddleware):
32
32
 
33
33
  try:
34
34
  # ENHANCED DEBUGGING: Log all request details
35
- logger.debug(f"๐Ÿ” OwnerMiddleware processing: {request.method} {request.url.path}")
36
-
35
+ logger.debug(
36
+ f"๐Ÿ” OwnerMiddleware processing: {request.method} {request.url.path}"
37
+ )
38
+
37
39
  # Extract owner_id from webhook URL pattern: /webhook/messenger/{owner_id}/{platform}
38
40
  if request.url.path.startswith("/webhook/"):
39
41
  logger.debug(f"๐ŸŽฏ Webhook request detected: {request.url.path}")
40
42
  path_parts = request.url.path.strip("/").split("/")
41
43
  logger.debug(f"๐Ÿ“‹ Path parts: {path_parts} (length: {len(path_parts)})")
42
-
44
+
43
45
  if len(path_parts) >= 4:
44
46
  # path_parts = ["webhook", "messenger", "owner_id", "platform"]
45
47
  owner_id = path_parts[2]
@@ -49,14 +51,18 @@ class OwnerMiddleware(BaseHTTPMiddleware):
49
51
  if self._is_valid_owner_id(owner_id):
50
52
  # Set owner_id context from URL
51
53
  set_request_context(owner_id=owner_id)
52
- logger.debug(f"โœ… Owner ID context set successfully: {owner_id}")
54
+ logger.debug(
55
+ f"โœ… Owner ID context set successfully: {owner_id}"
56
+ )
53
57
  else:
54
58
  logger.error(f"โŒ Invalid owner ID format: {owner_id}")
55
59
  raise HTTPException(
56
60
  status_code=400, detail=f"Invalid owner ID: {owner_id}"
57
61
  )
58
62
  else:
59
- logger.warning(f"โš ๏ธ Webhook URL does not have enough parts: {path_parts}")
63
+ logger.warning(
64
+ f"โš ๏ธ Webhook URL does not have enough parts: {path_parts}"
65
+ )
60
66
 
61
67
  # For non-webhook endpoints, use default owner from settings
62
68
  elif not self._is_public_endpoint(request.url.path):
@@ -161,10 +161,10 @@ def create_webhook_router(event_dispatcher: WappaEventDispatcher) -> APIRouter:
161
161
  # Generate webhook URLs for this platform and tenant
162
162
  try:
163
163
  platform_type = PlatformType(platform.lower())
164
- except ValueError:
164
+ except ValueError as e:
165
165
  raise HTTPException(
166
166
  status_code=400, detail=f"Unsupported platform: {platform}"
167
- )
167
+ ) from e
168
168
 
169
169
  webhook_url = webhook_url_factory.generate_webhook_url(platform_type, tenant_id)
170
170
  verify_url = webhook_url_factory.generate_webhook_url(
wappa/cli/__init__.py CHANGED
@@ -6,4 +6,4 @@ Provides command-line interface for Wappa development and deployment workflows.
6
6
 
7
7
  from .main import app
8
8
 
9
- __all__ = ["app"]
9
+ __all__ = ["app"]
@@ -1,8 +1,9 @@
1
1
  from wappa import Wappa
2
+
2
3
  from .master_event import MasterEventHandler
3
4
 
4
5
  app = Wappa()
5
6
  app.set_event_handler(MasterEventHandler())
6
7
 
7
8
  if __name__ == "__main__":
8
- app.run()
9
+ app.run()
@@ -1,8 +1,10 @@
1
1
  from wappa import WappaEventHandler
2
2
  from wappa.webhooks import IncomingMessageWebhook
3
3
 
4
+
4
5
  class MasterEventHandler(WappaEventHandler):
5
-
6
6
  async def process_message(self, webhook: IncomingMessageWebhook):
7
- await self.messenger.mark_as_read(webhook.message.message_id, webhook.user.user_id)
8
- await self.messenger.send_text("Welcome to Wappa", webhook.user.user_id)
7
+ await self.messenger.mark_as_read(
8
+ webhook.message.message_id, webhook.user.user_id
9
+ )
10
+ await self.messenger.send_text("Welcome to Wappa", webhook.user.user_id)
@@ -1 +1 @@
1
- """JSON Cache Example - SOLID Architecture Implementation"""
1
+ """JSON Cache Example - SOLID Architecture Implementation"""
@@ -46,28 +46,28 @@ from .master_event import JSONCacheExampleHandler
46
46
  def validate_configuration() -> bool:
47
47
  """
48
48
  Validate required configuration settings.
49
-
49
+
50
50
  Returns:
51
51
  True if configuration is valid, False otherwise
52
52
  """
53
-
53
+
54
54
  # Check required WhatsApp credentials
55
55
  missing_configs = []
56
-
56
+
57
57
  if not settings.wp_access_token:
58
58
  missing_configs.append("WP_ACCESS_TOKEN")
59
-
59
+
60
60
  if not settings.wp_phone_id:
61
61
  missing_configs.append("WP_PHONE_ID")
62
-
62
+
63
63
  if not settings.wp_bid:
64
64
  missing_configs.append("WP_BID")
65
-
65
+
66
66
  if missing_configs:
67
67
  logger.error(f"โŒ Missing required configuration: {', '.join(missing_configs)}")
68
68
  logger.error("๐Ÿ’ก Create a .env file with the required credentials")
69
69
  return False
70
-
70
+
71
71
  logger.info("โœ… Configuration validation passed")
72
72
  return True
73
73
 
@@ -75,14 +75,14 @@ def validate_configuration() -> bool:
75
75
  def display_startup_information() -> None:
76
76
  """
77
77
  Display startup information and demo features.
78
-
78
+
79
79
  Shows configuration status, architecture overview,
80
80
  and available demo features.
81
81
  """
82
82
  print(f"๐Ÿš€ Wappa v{__version__} - JSON Cache Example (SOLID Architecture)")
83
83
  print("=" * 80)
84
84
  print()
85
-
85
+
86
86
  print("๐Ÿ—๏ธ *SOLID ARCHITECTURE IMPLEMENTATION:*")
87
87
  print(" โ€ข Single Responsibility: Each score module has one specific concern")
88
88
  print(" โ€ข Open/Closed: New score modules can be added without modification")
@@ -90,22 +90,28 @@ def display_startup_information() -> None:
90
90
  print(" โ€ข Interface Segregation: Clean, focused interfaces for each concern")
91
91
  print(" โ€ข Dependency Inversion: Dependencies injected through abstractions")
92
92
  print()
93
-
93
+
94
94
  print("๐Ÿ“‹ *CONFIGURATION STATUS:*")
95
- print(f" โ€ข Access Token: {'โœ… Configured' if settings.wp_access_token else 'โŒ Missing'}")
96
- print(f" โ€ข Phone ID: {settings.wp_phone_id if settings.wp_phone_id else 'โŒ Missing'}")
95
+ print(
96
+ f" โ€ข Access Token: {'โœ… Configured' if settings.wp_access_token else 'โŒ Missing'}"
97
+ )
98
+ print(
99
+ f" โ€ข Phone ID: {settings.wp_phone_id if settings.wp_phone_id else 'โŒ Missing'}"
100
+ )
97
101
  print(f" โ€ข Business ID: {'โœ… Configured' if settings.wp_bid else 'โŒ Missing'}")
98
- print(f" โ€ข JSON Cache: โœ… No external dependencies required")
99
- print(f" โ€ข Environment: {'๐Ÿ› ๏ธ Development' if settings.is_development else '๐Ÿš€ Production'}")
102
+ print(" โ€ข JSON Cache: โœ… No external dependencies required")
103
+ print(
104
+ f" โ€ข Environment: {'๐Ÿ› ๏ธ Development' if settings.is_development else '๐Ÿš€ Production'}"
105
+ )
100
106
  print()
101
-
107
+
102
108
  print("๐ŸŽฏ *SCORE MODULES (BUSINESS LOGIC):*")
103
109
  print(" โ€ข UserManagementScore: User profile and caching logic")
104
110
  print(" โ€ข MessageHistoryScore: Message logging and /HISTORY command")
105
- print(" โ€ข StateCommandsScore: /WAPPA and /EXIT command processing")
111
+ print(" โ€ข StateCommandsScore: /WAPPA and /EXIT command processing")
106
112
  print(" โ€ข CacheStatisticsScore: Cache monitoring and /STATS command")
107
113
  print()
108
-
114
+
109
115
  print("๐Ÿงช *DEMO FEATURES:*")
110
116
  print(" 1. Send any message โ†’ User profile created/updated + message logged")
111
117
  print(" 2. Send '/WAPPA' โ†’ Enter special state with cache management")
@@ -114,15 +120,15 @@ def display_startup_information() -> None:
114
120
  print(" 5. Send '/HISTORY' โ†’ View your last 20 messages with timestamps")
115
121
  print(" 6. Send '/STATS' โ†’ View comprehensive cache statistics")
116
122
  print()
117
-
123
+
118
124
  print("๐Ÿ’Ž *JSON CACHE ARCHITECTURE:*")
119
125
  print(" โ€ข user_cache: User profiles stored in {project_root}/cache/users/")
120
- print(" โ€ข table_cache: Message history in {project_root}/cache/tables/")
126
+ print(" โ€ข table_cache: Message history in {project_root}/cache/tables/")
121
127
  print(" โ€ข state_cache: Command state management in {project_root}/cache/states/")
122
128
  print(" โ€ข TTL Support: Metadata-based expiration with lazy cleanup")
123
129
  print(" โ€ข File Safety: Atomic write operations prevent corruption")
124
130
  print()
125
-
131
+
126
132
  print("๐Ÿ”ง *TECHNICAL FEATURES:*")
127
133
  print(" โ€ข File-based persistence with project root auto-detection")
128
134
  print(" โ€ข BaseModel JSON serialization with datetime handling")
@@ -139,22 +145,22 @@ def display_startup_information() -> None:
139
145
  def create_wappa_application() -> Wappa:
140
146
  """
141
147
  Create and configure the Wappa application.
142
-
148
+
143
149
  This function follows Single Responsibility Principle by focusing
144
150
  only on application creation and initial configuration.
145
-
151
+
146
152
  Returns:
147
153
  Configured Wappa application instance
148
154
  """
149
-
155
+
150
156
  try:
151
157
  # Create Wappa instance with JSON cache
152
158
  logger.info("๐Ÿ—๏ธ Creating Wappa application with JSON cache...")
153
159
  app = Wappa(cache="json")
154
-
160
+
155
161
  logger.info("โœ… Wappa application created successfully")
156
162
  return app
157
-
163
+
158
164
  except Exception as e:
159
165
  logger.error(f"โŒ Failed to create Wappa application: {e}")
160
166
  raise
@@ -163,51 +169,55 @@ def create_wappa_application() -> Wappa:
163
169
  def main() -> None:
164
170
  """
165
171
  Main application entry point.
166
-
172
+
167
173
  Demonstrates SOLID principles in action:
168
174
  - Single Responsibility: Each function has one clear purpose
169
175
  - Dependency Inversion: Dependencies flow from abstractions
170
176
  - Open/Closed: System is open for extension via score modules
171
177
  """
172
-
178
+
173
179
  logger.info("๐Ÿš€ Starting JSON Cache Example with SOLID Architecture")
174
-
180
+
175
181
  try:
176
182
  # Display startup information
177
183
  display_startup_information()
178
-
184
+
179
185
  # Validate configuration before proceeding
180
186
  if not validate_configuration():
181
- logger.error("โŒ Configuration validation failed - cannot start application")
187
+ logger.error(
188
+ "โŒ Configuration validation failed - cannot start application"
189
+ )
182
190
  return
183
-
191
+
184
192
  # Create Wappa application
185
193
  app = create_wappa_application()
186
-
194
+
187
195
  # Create and set the SOLID WappaEventHandler implementation
188
196
  handler = JSONCacheExampleHandler()
189
197
  app.set_event_handler(handler)
190
-
191
- logger.info("โœ… Application initialization completed with SOLID WappaEventHandler")
192
-
198
+
199
+ logger.info(
200
+ "โœ… Application initialization completed with SOLID WappaEventHandler"
201
+ )
202
+
193
203
  print("๐ŸŒ Starting SOLID JSON cache demo server...")
194
204
  print("๐Ÿ’ก Press CTRL+C to stop the server")
195
205
  print("๐Ÿ’พ Cache files will be created in the project's cache/ directory")
196
206
  print("=" * 80)
197
207
  print()
198
-
208
+
199
209
  # Start the application
200
210
  # The framework will handle dependency injection automatically
201
211
  app.run()
202
-
212
+
203
213
  except KeyboardInterrupt:
204
214
  logger.info("๐Ÿ‘‹ Application stopped by user")
205
215
  print("\n๐Ÿ‘‹ JSON cache demo stopped by user")
206
-
216
+
207
217
  except Exception as e:
208
218
  logger.error(f"โŒ Application startup error: {e}", exc_info=True)
209
219
  print(f"\nโŒ Server error: {e}")
210
-
220
+
211
221
  finally:
212
222
  logger.info("๐Ÿ JSON cache demo completed")
213
223
  print("๐Ÿ JSON cache demo completed")
@@ -219,17 +229,19 @@ def main() -> None:
219
229
  try:
220
230
  logger.info("๐Ÿ“ฆ Creating module-level Wappa application instance")
221
231
  app = Wappa(cache="json")
222
-
232
+
223
233
  # Create and set the SOLID WappaEventHandler implementation
224
234
  handler = JSONCacheExampleHandler()
225
235
  app.set_event_handler(handler)
226
-
227
- logger.info("โœ… Module-level application instance ready with SOLID WappaEventHandler")
228
-
236
+
237
+ logger.info(
238
+ "โœ… Module-level application instance ready with SOLID WappaEventHandler"
239
+ )
240
+
229
241
  except Exception as e:
230
242
  logger.error(f"โŒ Failed to create module-level app instance: {e}")
231
243
  raise
232
244
 
233
245
 
234
246
  if __name__ == "__main__":
235
- main()
247
+ main()