pyview-web 0.4.2__py3-none-any.whl → 0.4.3__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 pyview-web might be problematic. Click here for more details.

pyview/live_socket.py CHANGED
@@ -47,9 +47,18 @@ class UnconnectedSocket(Generic[T]):
47
47
  connected: bool = False
48
48
 
49
49
  def allow_upload(
50
- self, upload_name: str, constraints: UploadConstraints, auto_upload: bool = False, progress: Optional[Callable] = None
50
+ self,
51
+ upload_name: str,
52
+ constraints: UploadConstraints,
53
+ auto_upload: bool = False,
54
+ progress: Optional[Callable] = None,
51
55
  ) -> UploadConfig:
52
- return UploadConfig(name=upload_name, constraints=constraints, autoUpload=auto_upload, progress_callback=progress)
56
+ return UploadConfig(
57
+ name=upload_name,
58
+ constraints=constraints,
59
+ autoUpload=auto_upload,
60
+ progress_callback=progress,
61
+ )
53
62
 
54
63
 
55
64
  class ConnectedLiveViewSocket(Generic[T]):
@@ -193,13 +202,38 @@ class ConnectedLiveViewSocket(Generic[T]):
193
202
  except Exception:
194
203
  logger.warning("Error sending navigation message", exc_info=True)
195
204
 
205
+ async def redirect(self, path: str, params: dict[str, Any] = {}):
206
+ """Redirect to a new location with full page reload"""
207
+ to = path
208
+ if params:
209
+ to = to + "?" + urlencode(params)
210
+
211
+ message = [
212
+ None,
213
+ None,
214
+ self.topic,
215
+ "redirect",
216
+ {"to": to},
217
+ ]
218
+
219
+ try:
220
+ await self.websocket.send_text(json.dumps(message))
221
+ except Exception:
222
+ logger.warning("Error sending redirect message", exc_info=True)
223
+
196
224
  async def push_event(self, event: str, value: dict[str, Any]):
197
225
  self.pending_events.append((event, value))
198
226
 
199
227
  def allow_upload(
200
- self, upload_name: str, constraints: UploadConstraints, auto_upload: bool = False, progress: Optional[Callable] = None
228
+ self,
229
+ upload_name: str,
230
+ constraints: UploadConstraints,
231
+ auto_upload: bool = False,
232
+ progress: Optional[Callable] = None,
201
233
  ) -> UploadConfig:
202
- return self.upload_manager.allow_upload(upload_name, constraints, auto_upload, progress)
234
+ return self.upload_manager.allow_upload(
235
+ upload_name, constraints, auto_upload, progress
236
+ )
203
237
 
204
238
  async def close(self):
205
239
  self.connected = False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyview-web
3
- Version: 0.4.2
3
+ Version: 0.4.3
4
4
  Summary: LiveView in Python
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -21,7 +21,7 @@ pyview/instrumentation/interfaces.py,sha256=AhVDM_vzETWtM-wfOXaM13K2OgdL0H8lu5wh
21
21
  pyview/instrumentation/noop.py,sha256=VP8UjiI--A7KWqnSFh7PMG7MqY0Z9ddQjBYVW7iHZa0,2941
22
22
  pyview/js.py,sha256=E6HMsUfXQjrcLqYq26ieeYuzTjBeZqfJwwOm3uSR4ME,3498
23
23
  pyview/live_routes.py,sha256=IN2Jmy8b1umcfx1R7ZgFXHZNbYDJp_kLIbADtDJknPM,1749
24
- pyview/live_socket.py,sha256=s41hancNG_hJOl17SSSc2Bg2UzxbBF8mihk4AedFy3k,6972
24
+ pyview/live_socket.py,sha256=SjN2TSYHnMgmzjE3rVZkNBxtZ0EA3Wx3frg7tx85YBY,7655
25
25
  pyview/live_view.py,sha256=mwAp7jiABSZCBgYF-GLQCB7zcJ7Wpz9cuC84zjzsp2U,1455
26
26
  pyview/meta.py,sha256=01Z-qldB9jrewmIJHQpUqyIhuHodQGgCvpuY9YM5R6c,74
27
27
  pyview/phx_message.py,sha256=DUdPfl6tlw9K0FNXJ35ehq03JGgynvwA_JItHQ_dxMQ,2007
@@ -51,8 +51,8 @@ pyview/vendor/ibis/template.py,sha256=6XJXnztw87CrOaKeW3e18LL0fNM8AI6AaK_QgMdb7e
51
51
  pyview/vendor/ibis/tree.py,sha256=hg8f-fKHeo6DE8R-QgAhdvEaZ8rKyz7p0nGwPy0CBTs,2509
52
52
  pyview/vendor/ibis/utils.py,sha256=nLSaxPR9vMphzV9qinlz_Iurv9c49Ps6Knv8vyNlewU,2768
53
53
  pyview/ws_handler.py,sha256=f6iI4vvLesepI9tCTHLyRBbdKCGPS6Gzj_UUjfIrPT8,14722
54
- pyview_web-0.4.2.dist-info/METADATA,sha256=-tCEwOMH_NssPzXFOfuhSwVQ75TpDGiV6ltYZ3HXsSE,5280
55
- pyview_web-0.4.2.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
56
- pyview_web-0.4.2.dist-info/entry_points.txt,sha256=GAT-ic-VYmmSMUSUVKdV1bp4w-vgEeVP-XzElvarQ9U,42
57
- pyview_web-0.4.2.dist-info/licenses/LICENSE,sha256=M_bADaBm9_MV9llX3lCicksLhwk3eZUjA2srE0uUWr0,1071
58
- pyview_web-0.4.2.dist-info/RECORD,,
54
+ pyview_web-0.4.3.dist-info/METADATA,sha256=uqYhaTBqJQgHBz5s2S33GfRp7BeVPNEmAuaQcitesNk,5280
55
+ pyview_web-0.4.3.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
56
+ pyview_web-0.4.3.dist-info/entry_points.txt,sha256=GAT-ic-VYmmSMUSUVKdV1bp4w-vgEeVP-XzElvarQ9U,42
57
+ pyview_web-0.4.3.dist-info/licenses/LICENSE,sha256=M_bADaBm9_MV9llX3lCicksLhwk3eZUjA2srE0uUWr0,1071
58
+ pyview_web-0.4.3.dist-info/RECORD,,