Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-advanced-user-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
caosdb
Software
caosdb-advanced-user-tools
Commits
94a3c46b
Commit
94a3c46b
authored
4 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
MAINT: use update arguments in guard
parent
8c3897ce
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!22
Release 0.3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caosadvancedtools/crawler.py
+2
-2
2 additions, 2 deletions
src/caosadvancedtools/crawler.py
src/caosadvancedtools/guard.py
+5
-6
5 additions, 6 deletions
src/caosadvancedtools/guard.py
with
7 additions
and
8 deletions
src/caosadvancedtools/crawler.py
+
2
−
2
View file @
94a3c46b
...
@@ -491,7 +491,7 @@ carefully and if the changes are ok, click on the following link:
...
@@ -491,7 +491,7 @@ carefully and if the changes are ok, click on the following link:
logger
.
debug
(
cfood
.
to_be_updated
)
logger
.
debug
(
cfood
.
to_be_updated
)
try
:
try
:
guard
.
safe_update
(
cfood
.
to_be_updated
)
guard
.
safe_update
(
cfood
.
to_be_updated
,
unique
=
False
)
except
ProhibitedException
:
except
ProhibitedException
:
self
.
update_cache
.
insert
(
cfood
.
to_be_updated
,
self
.
run_id
)
self
.
update_cache
.
insert
(
cfood
.
to_be_updated
,
self
.
run_id
)
except
Exception
as
e
:
except
Exception
as
e
:
...
@@ -539,7 +539,7 @@ carefully and if the changes are ok, click on the following link:
...
@@ -539,7 +539,7 @@ carefully and if the changes are ok, click on the following link:
logger
.
debug
(
"
No new entities to be inserted.
"
)
logger
.
debug
(
"
No new entities to be inserted.
"
)
else
:
else
:
try
:
try
:
guard
.
safe_insert
(
missing_identifiables
)
guard
.
safe_insert
(
missing_identifiables
,
unique
=
False
)
except
Exception
as
e
:
except
Exception
as
e
:
DataModelProblems
.
evaluate_exception
(
e
)
DataModelProblems
.
evaluate_exception
(
e
)
...
...
This diff is collapsed.
Click to expand it.
src/caosadvancedtools/guard.py
+
5
−
6
View file @
94a3c46b
...
@@ -20,7 +20,6 @@
...
@@ -20,7 +20,6 @@
import
caosdb
as
db
import
caosdb
as
db
RETRIEVE
=
0
RETRIEVE
=
0
INSERT
=
1
INSERT
=
1
UPDATE
=
2
UPDATE
=
2
...
@@ -36,10 +35,10 @@ class Guard(object):
...
@@ -36,10 +35,10 @@ class Guard(object):
self
.
freshly_created
=
[]
self
.
freshly_created
=
[]
self
.
level
=
level
self
.
level
=
level
def
safe_insert
(
self
,
obj
):
def
safe_insert
(
self
,
obj
,
*
args
,
**
kwargs
):
if
self
.
level
<
INSERT
:
if
self
.
level
<
INSERT
:
raise
ProhibitedException
(
"
not allowed
"
)
raise
ProhibitedException
(
"
not allowed
"
)
obj
.
insert
()
obj
.
insert
(
*
args
,
**
kwargs
)
if
isinstance
(
obj
,
db
.
Container
):
if
isinstance
(
obj
,
db
.
Container
):
self
.
freshly_created
.
extend
([
self
.
freshly_created
.
extend
([
...
@@ -47,7 +46,7 @@ class Guard(object):
...
@@ -47,7 +46,7 @@ class Guard(object):
else
:
else
:
self
.
freshly_created
.
append
(
obj
.
id
)
self
.
freshly_created
.
append
(
obj
.
id
)
def
safe_update
(
self
,
obj
,
**
kwargs
):
def
safe_update
(
self
,
obj
,
*
args
,
**
kwargs
):
if
isinstance
(
obj
,
db
.
Container
):
if
isinstance
(
obj
,
db
.
Container
):
all_fresh
=
True
all_fresh
=
True
...
@@ -58,12 +57,12 @@ class Guard(object):
...
@@ -58,12 +57,12 @@ class Guard(object):
if
self
.
level
<
UPDATE
and
not
all_fresh
:
if
self
.
level
<
UPDATE
and
not
all_fresh
:
raise
ProhibitedException
(
"
not allowed
"
)
raise
ProhibitedException
(
"
not allowed
"
)
else
:
else
:
obj
.
update
(
**
kwargs
)
obj
.
update
(
*
args
,
**
kwargs
)
else
:
else
:
if
self
.
level
<
UPDATE
and
obj
.
id
not
in
self
.
freshly_created
:
if
self
.
level
<
UPDATE
and
obj
.
id
not
in
self
.
freshly_created
:
raise
ProhibitedException
(
"
not allowed
"
)
raise
ProhibitedException
(
"
not allowed
"
)
else
:
else
:
obj
.
update
(
**
kwargs
)
obj
.
update
(
*
args
,
**
kwargs
)
def
set_level
(
self
,
level
):
def
set_level
(
self
,
level
):
self
.
level
=
level
self
.
level
=
level
...
...
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