actions: Delete zerver.lib.actions.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2022-04-13 15:48:36 -07:00
parent 729019acdd
commit cc30ed8ec7
12 changed files with 12 additions and 14 deletions

View File

@ -288,7 +288,7 @@ def do_aggregate_to_summary_table(
## Utility functions called from outside counts.py ## ## Utility functions called from outside counts.py ##
# called from zerver/lib/actions.py; should not throw any errors # called from zerver.actions; should not throw any errors
def do_increment_logging_stat( def do_increment_logging_stat(
zerver_object: Union[Realm, UserProfile, Stream], zerver_object: Union[Realm, UserProfile, Stream],
stat: CountStat, stat: CountStat,

View File

@ -155,7 +155,7 @@ object before the first thread wrote out its change.
### Using raw saves to update important model objects ### Using raw saves to update important model objects
In most cases, we already have a function in zerver/lib/actions.py with In most cases, we already have a function in `zerver.actions` with
a name like do_activate_user that will correctly handle lookups, a name like do_activate_user that will correctly handle lookups,
caching, and notifying running browsers via the event system about your caching, and notifying running browsers via the event system about your
change. So please check whether such a function exists before writing change. So please check whether such a function exists before writing

View File

@ -23,7 +23,7 @@ paths will be familiar to Django developers.
- `zerver/lib/*.py` Most library code. - `zerver/lib/*.py` Most library code.
- `zerver/lib/actions.py` Most code doing writes to user-facing - `zerver/actions/*.py` Most code doing writes to user-facing
database tables lives here. In particular, we have a policy that database tables lives here. In particular, we have a policy that
all code calling `send_event` to trigger [pushing data to all code calling `send_event` to trigger [pushing data to
clients](../subsystems/events-system.md) must live here. clients](../subsystems/events-system.md) must live here.

View File

@ -91,12 +91,12 @@ database, for most objects, in addition to saving the changes to the
database, one may also need to flush caches, notify the apps and open database, one may also need to flush caches, notify the apps and open
browser windows, and record the change in Zulip's `RealmAuditLog` browser windows, and record the change in Zulip's `RealmAuditLog`
audit history table. For almost any data change you want to do, there audit history table. For almost any data change you want to do, there
is already a function in `zerver.lib.actions.py` with a name like is already a function in `zerver.actions` with a name like
`do_change_full_name` that updates that field and notifies clients `do_change_full_name` that updates that field and notifies clients
correctly. correctly.
For convenience, Zulip automatically import `zerver/models.py` and For convenience, Zulip automatically imports `zerver/models.py`
`zerver/lib/actions.py` into every management shell; if you need to into every management shell; if you need to
access other functions, you'll need to import them yourself. access other functions, you'll need to import them yourself.
## Other useful manage.py commands ## Other useful manage.py commands

View File

@ -51,7 +51,7 @@ project.
(and ideally, also used in Zulip's existing code). Look for code in (and ideally, also used in Zulip's existing code). Look for code in
`zerver/lib/` that already does what you need. For most actions, `zerver/lib/` that already does what you need. For most actions,
you can just call a `do_change_foo` type function from you can just call a `do_change_foo` type function from
`zerver/lib/actions.py` to do all the work; this is usually far `zerver/actions/` to do all the work; this is usually far
better than manipulating the database directly, since the library better than manipulating the database directly, since the library
functions used by the UI are maintained to correctly live-update the functions used by the UI are maintained to correctly live-update the
UI if needed. UI if needed.

View File

@ -32,7 +32,7 @@ because it takes a long time. Instead, your edit/refresh cycle will
typically involve running subsets of the tests with commands like these: typically involve running subsets of the tests with commands like these:
```bash ```bash
./tools/lint zerver/lib/actions.py # Lint the file you just changed ./tools/lint zerver/models.py # Lint the file you just changed
./tools/test-backend zerver.tests.test_markdown.MarkdownTest.test_inline_youtube ./tools/test-backend zerver.tests.test_markdown.MarkdownTest.test_inline_youtube
./tools/test-backend MarkdownTest # Run `test-backend --help` for more options ./tools/test-backend MarkdownTest # Run `test-backend --help` for more options
./tools/test-js-with-node util ./tools/test-js-with-node util

View File

@ -242,7 +242,7 @@ change the server more than once or cause unwanted side effects.
### Making changes to the database ### Making changes to the database
If the view does any modification to the database, that change is done If the view does any modification to the database, that change is done
in a helper function in `zerver/lib/actions.py`. Those functions are in a helper function in `zerver/actions/*.py`. Those functions are
responsible for doing a complete update to the state of the server, responsible for doing a complete update to the state of the server,
which often entails both updating the database and sending any events which often entails both updating the database and sending any events
to notify clients about the state change. When possible, we prefer to to notify clients about the state change. When possible, we prefer to

View File

@ -2,7 +2,6 @@ try:
from django.conf import settings # noqa: F401 from django.conf import settings # noqa: F401
from analytics.models import * # noqa: F401, F403 from analytics.models import * # noqa: F401, F403
from zerver.lib.actions import * # noqa: F401, F403
from zerver.models import * # noqa: F401, F403 from zerver.models import * # noqa: F401, F403
except Exception: except Exception:
import traceback import traceback

View File

@ -374,7 +374,7 @@ python_rules = RuleList(
}, },
{ {
"pattern": "get_stream[(]", "pattern": "get_stream[(]",
"include_only": {"zerver/views/", "zerver/actions/", "zerver/lib/actions.py"}, "include_only": {"zerver/views/", "zerver/actions/"},
"exclude_line": { "exclude_line": {
# This one in check_message is kinda terrible, since it's # This one in check_message is kinda terrible, since it's
# how most instances are written, but better to exclude something than nothing # how most instances are written, but better to exclude something than nothing

View File

@ -88,7 +88,7 @@ if __name__ == "__main__":
time.sleep(1.3) time.sleep(1.3)
print("Attempting to modify a file") print("Attempting to modify a file")
os.utime("zerver/lib/actions.py") os.utime("zerver/models.py")
failed = check_worker_launch(run_dev) failed = check_worker_launch(run_dev)
run_dev.send_signal(signal.SIGINT) run_dev.send_signal(signal.SIGINT)

View File

@ -1 +0,0 @@

View File

@ -149,7 +149,7 @@ def send_notification_http(realm: Realm, data: Mapping[str, Any]) -> None:
# The core function for sending an event from Django to Tornado (which # The core function for sending an event from Django to Tornado (which
# will then push it to web and mobile clients for the target users). # will then push it to web and mobile clients for the target users).
# By convention, send_event should only be called from # By convention, send_event should only be called from
# zerver/lib/actions.py, which helps make it easy to find event # zerver/actions/*.py, which helps make it easy to find event
# generation code. # generation code.
# #
# Every call point should be covered by a test in `test_events.py`, # Every call point should be covered by a test in `test_events.py`,