Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djangoldp-notification
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
djangoldp-packages
djangoldp-notification
Commits
3e919022
Commit
3e919022
authored
4 years ago
by
Calum Mackervoy
Committed by
Jean-Baptiste Pasquier
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
bugfix: catching ObjectDoesNotExist in notifications listener
parent
32f4c8fa
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
djangoldp_notification/models.py
+4
-1
4 additions, 1 deletion
djangoldp_notification/models.py
with
4 additions
and
1 deletion
djangoldp_notification/models.py
+
4
−
1
View file @
3e919022
...
...
@@ -3,6 +3,7 @@ import logging
import
requests
from
django.conf
import
settings
from
django.core.mail
import
send_mail
from
django.core.exceptions
import
ObjectDoesNotExist
from
django.db
import
models
from
django.db.models.signals
import
post_save
,
post_delete
from
django.dispatch
import
receiver
...
...
@@ -123,11 +124,13 @@ def send_notification(sender, instance, **kwargs):
(
not
subscription
.
is_backlink
or
not
kwargs
.
get
(
"
created
"
)):
# I may have configured to send the subscription to a foreign key
if
subscription
.
field
is
not
None
and
len
(
subscription
.
field
)
>
1
:
instance
=
getattr
(
instance
,
subscription
.
field
,
instance
)
try
:
instance
=
getattr
(
instance
,
subscription
.
field
,
instance
)
url_resource
=
settings
.
BASE_URL
+
Model
.
resource_id
(
instance
)
except
NoReverseMatch
:
continue
except
ObjectDoesNotExist
:
continue
process
=
Thread
(
target
=
send_request
,
args
=
[
subscription
.
inbox
,
url_resource
,
instance
,
kwargs
.
get
(
"
created
"
,
False
)])
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment