Quellcode durchsuchen

improve the document of storage (#3731)

Add “Needs `storage_secret`” to table. Improve description of `app.storage.user` and `app.storage.browser`.
PythonPan vor 8 Monaten
Ursprung
Commit
fe3cbc22f2
1 geänderte Dateien mit 7 neuen und 4 gelöschten Zeilen
  1. 7 4
      website/documentation/content/storage_documentation.py

+ 7 - 4
website/documentation/content/storage_documentation.py

@@ -32,17 +32,19 @@ doc.title('Storage')
         Stored server-side, each dictionary is associated with a unique identifier held in a browser session cookie.
         Stored server-side, each dictionary is associated with a unique identifier held in a browser session cookie.
         Unique to each user, this storage is accessible across all their browser tabs.
         Unique to each user, this storage is accessible across all their browser tabs.
         `app.storage.browser['id']` is used to identify the user.
         `app.storage.browser['id']` is used to identify the user.
+        This storage is only available within [page builder functions](/documentation/page) 
+        and requires the `storage_secret` parameter in`ui.run()` to sign the browser session cookie.
     - `app.storage.general`:
     - `app.storage.general`:
         Also stored server-side, this dictionary provides a shared storage space accessible to all users.
         Also stored server-side, this dictionary provides a shared storage space accessible to all users.
     - `app.storage.browser`:
     - `app.storage.browser`:
         Unlike the previous types, this dictionary is stored directly as the browser session cookie, shared among all browser tabs for the same user.
         Unlike the previous types, this dictionary is stored directly as the browser session cookie, shared among all browser tabs for the same user.
         However, `app.storage.user` is generally preferred due to its advantages in reducing data payload, enhancing security, and offering larger storage capacity.
         However, `app.storage.user` is generally preferred due to its advantages in reducing data payload, enhancing security, and offering larger storage capacity.
         By default, NiceGUI holds a unique identifier for the browser session in `app.storage.browser['id']`.
         By default, NiceGUI holds a unique identifier for the browser session in `app.storage.browser['id']`.
+        This storage is only available within [page builder functions](/documentation/page) 
+        and requires the `storage_secret` parameter in`ui.run()` to sign the browser session cookie.
 
 
-    The user storage and browser storage are only available within `page builder functions </documentation/page>`_
-    because they are accessing the underlying `Request` object from FastAPI.
-    Additionally these two types require the `storage_secret` parameter in`ui.run()` to sign the browser session cookie.
-
+    The following table will help you to choose storage.
+ 
     | Storage type                | `tab`  | `client` | `user` | `general` | `browser` |
     | Storage type                | `tab`  | `client` | `user` | `general` | `browser` |
     |-----------------------------|--------|----------|--------|-----------|-----------|
     |-----------------------------|--------|----------|--------|-----------|-----------|
     | Location                    | Server | Server   | Server | Server    | Browser   |
     | Location                    | Server | Server   | Server | Server    | Browser   |
@@ -54,6 +56,7 @@ doc.title('Storage')
     | Needs client connection     | Yes    | No       | No     | No        | No        |
     | Needs client connection     | Yes    | No       | No     | No        | No        |
     | Write only before response  | No     | No       | No     | No        | Yes       |
     | Write only before response  | No     | No       | No     | No        | Yes       |
     | Needs serializable data     | No     | No       | Yes    | Yes       | Yes       |
     | Needs serializable data     | No     | No       | Yes    | Yes       | Yes       |
+    | Needs `storage_secret`      | No     | No       | Yes    | No        | Yes       |
 ''')
 ''')
 def storage_demo():
 def storage_demo():
     from nicegui import app
     from nicegui import app