-
-
Notifications
You must be signed in to change notification settings - Fork 11
update docs, upgrade signals #430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
devkral
wants to merge
19
commits into
main
Choose a base branch
from
devkral/features/docs_and_signals
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
9714813
update docs, upgrade signals
devkral 4a10d78
fix typings
devkral 185c34c
fix some hazards, allow None values in the returned arrays
devkral 47f2a34
fix missing cleanup
devkral dfc2264
fixes, improve tests
devkral 4e4354f
cache fixes
devkral c45d0dd
fix
devkral bc71a88
fix typings, fix missing await
devkral df9d46f
improve variable descriptions, and change _get_raw
devkral dadd672
fix naming
devkral cbaebb5
Update docs/queries/bulk.md
devkral d451849
fix documentation
devkral fda1e5f
harden
devkral 9b7b326
fix caching
devkral 649ad17
fix recursion error
devkral 7ccc493
check result
devkral 5515ca9
add warning for pytest<9
devkral b5cbffa
fix docs
devkral 3592945
add a lot of cache tests, some fixes
devkral File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import edgy | ||
| from edgy.exceptions import SkipOperation | ||
|
|
||
|
|
||
| class BaseModel(edgy.StrictModel): | ||
| protected = edgy.BooleanField(default=False) | ||
|
|
||
| class Meta: | ||
| registry = ... | ||
| abstract = True | ||
|
|
||
|
|
||
| class Friend(BaseModel): | ||
| name = edgy.CharField(max_length=100) | ||
|
|
||
|
|
||
| class Profile(BaseModel): | ||
| name = edgy.CharField(max_length=100) | ||
|
|
||
|
|
||
| class User(BaseModel): | ||
| name = edgy.CharField(max_length=100) | ||
| profile = edgy.ForeignKey("Profile", null=True, on_delete=edgy.CASCADE, related_name="users") | ||
| friends = edgy.ManyToMany("Friend", related_name="users") | ||
|
|
||
|
|
||
| @User.meta.signals.pre_relation_remove.connect_via(User) | ||
| @Profile.meta.signals.pre_relation_remove.connect_via(Profile) | ||
| async def excempt_removal_relation(sender, raw_values, **kwargs): | ||
| new_raw_values = list(raw_values) | ||
| raw_values.clear() | ||
| for value in new_raw_values: | ||
| if not value.protected: | ||
| raw_values.append(value) | ||
|
|
||
|
|
||
| @User.meta.signals.pre_delete.connect_via(User) | ||
| @Profile.meta.signals.pre_delete.connect_via(Profile) | ||
| async def abort_removal_relation(sender, model_instance, injected_filters, **kwargs): | ||
| if model_instance is None: | ||
| injected_filters.append({"protected": True}) | ||
| else: | ||
| if model_instance.protected: | ||
| raise SkipOperation() | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: The queryset branch of this doc's
pre_deletehandler injects{"protected": True}, which (viaqueryset.filter(*injected_filters)) makes the delete target only the protected rows — the exact rows the example is meant to exempt. The per-model branch above it skips deletion ofprotected=Truerows, so the two branches contradict each other. The filter should beinjected_filters.append({"protected": False})(matching the pattern used intests/signals/test_deletion_signals_skip.pywith{"protection": False}) so that protected records are left untouched.Prompt for AI agents