plain 0.39.0__py3-none-any.whl → 0.39.1__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.
plain/chores/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # Chores
2
+
3
+ **Routine maintenance tasks.**
4
+
5
+ Chores are registered functions that can be run at any time to keep an app in a desirable state.
6
+
7
+ ![](https://assets.plainframework.com/docs/plain-chores-run.png)
8
+
9
+ A good example is the clearing of expired sessions in [`plain.sessions`](/plain-sessions/plain/sessions/chores.py) — since the sessions are stored in the database, occasionally you will want to delete any sessions that are expired and no longer in use.
10
+
11
+ ```python
12
+ # plain/sessions/chores.py
13
+ from plain.chores import register_chore
14
+ from plain.utils import timezone
15
+
16
+ from .models import Session
17
+
18
+
19
+ @register_chore("sessions")
20
+ def clear_expired():
21
+ """
22
+ Delete sessions that have expired.
23
+ """
24
+ result = Session.objects.filter(expires_at__lt=timezone.now()).delete()
25
+ return f"{result[0]} expired sessions deleted"
26
+ ```
27
+
28
+ ## Running chores
29
+
30
+ The `plain chores run` command will execute all registered chores. When and how to run this is up to the user, but running them hourly is a safe assumption in most cases (assuming you have any chores — `plain chores list`).
31
+
32
+ There are several ways you can run chores depending on your needs:
33
+
34
+ - on deploy
35
+ - as a [`plain.worker` scheduled job](/plain-worker/plain/worker/README.md#scheduled-jobs)
36
+ - as a cron job (using any cron-like system where your app is hosted)
37
+ - manually as needed
38
+
39
+ ## Writing chores
40
+
41
+ A chore is a function decorated with `@register_chore(chore_group_name)`. It can write a description as a docstring, and it can return a value that will be printed when the chore is run.
42
+
43
+ ```python
44
+ # app/chores.py
45
+ from plain.chores import register_chore
46
+
47
+
48
+ @register_chore("app")
49
+ def chore_name():
50
+ """
51
+ A chore description can go here
52
+ """
53
+ # Do a thing!
54
+ return "We did it!"
55
+ ```
56
+
57
+ A good chore is:
58
+
59
+ - Fast
60
+ - Idempotent
61
+ - Recurring
62
+ - Stateless
63
+
64
+ If chores are written in `app/chores.py` or `{pkg}/chores.py`, then they will be imported automatically and registered.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plain
3
- Version: 0.39.0
3
+ Version: 0.39.1
4
4
  Summary: A web framework for building products with Python.
5
5
  Author-email: Dave Gaeddert <dave.gaeddert@dropseed.dev>
6
6
  License-File: LICENSE
@@ -14,6 +14,7 @@ plain/assets/finders.py,sha256=2k8QZAbfUbc1LykxbzdazTSB6xNxJZnsZaGhWbSFZZs,1452
14
14
  plain/assets/fingerprints.py,sha256=2LPHLUkoITMseLDmemTpBtMRDWCR2H5GAHjC6AN4gz0,1367
15
15
  plain/assets/urls.py,sha256=zQUA8bAlh9qVqskPJJrqWd9DjvetOi5jPSqy4vUX0J4,1161
16
16
  plain/assets/views.py,sha256=T_0Qh6v9qBerEBYbhToigwOzsij-x1z_R-1zETQcIh0,9447
17
+ plain/chores/README.md,sha256=Da8Nw8ZF7PlAE_iVb0AqJGbLOu0F6HC0cj1K451KBak,1946
17
18
  plain/chores/__init__.py,sha256=r9TXtQCH-VbvfnIJ5F8FxgQC35GRWFOfmMZN3q9niLg,67
18
19
  plain/chores/registry.py,sha256=V3WjuekRI22LFvJbqSkUXQtiOtuE2ZK8gKV1TRvxRUI,1866
19
20
  plain/cli/README.md,sha256=ompPcgzY2Fdpm579ITmCpFIaZIsiXYbfD61mqkq312M,1860
@@ -145,8 +146,8 @@ plain/views/forms.py,sha256=ESZOXuo6IeYixp1RZvPb94KplkowRiwO2eGJCM6zJI0,2400
145
146
  plain/views/objects.py,sha256=GGbcfg_9fPZ-PiaBwIHG2e__8GfWDR7JQtQ15wTyiHg,5970
146
147
  plain/views/redirect.py,sha256=vMXx8430FtyKcT0V0gyY92SkLtyULBX52KhX4eu4gEA,1985
147
148
  plain/views/templates.py,sha256=kMcHKkKNvucF91SFGkaq-ugjrCwn4zJBpFV1JkwA544,2027
148
- plain-0.39.0.dist-info/METADATA,sha256=DlIAs31jS4S87R0UhAlZlYdgxZGKOebjo3IcgK5yas4,4297
149
- plain-0.39.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
150
- plain-0.39.0.dist-info/entry_points.txt,sha256=1Ys2lsSeMepD1vz8RSrJopna0RQfUd951vYvCRsvl6A,45
151
- plain-0.39.0.dist-info/licenses/LICENSE,sha256=m0D5O7QoH9l5Vz_rrX_9r-C8d9UNr_ciK6Qwac7o6yo,3175
152
- plain-0.39.0.dist-info/RECORD,,
149
+ plain-0.39.1.dist-info/METADATA,sha256=e8tEYf656PoEDJU624eCgDYMAT9_Jc1ewukJa45-_7g,4297
150
+ plain-0.39.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
151
+ plain-0.39.1.dist-info/entry_points.txt,sha256=1Ys2lsSeMepD1vz8RSrJopna0RQfUd951vYvCRsvl6A,45
152
+ plain-0.39.1.dist-info/licenses/LICENSE,sha256=m0D5O7QoH9l5Vz_rrX_9r-C8d9UNr_ciK6Qwac7o6yo,3175
153
+ plain-0.39.1.dist-info/RECORD,,
File without changes