Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
PyI40AAS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lehrstuhl für Informations- und Automatisierungssysteme
PyI40AAS
Commits
1a466d5c
Commit
1a466d5c
authored
Nov 5, 2020
by
Michael Thies
Browse files
Options
Downloads
Patches
Plain Diff
backends.couchdb: Improve discard(): Use HEAD request to fetch current revision
parent
88e6ac02
No related branches found
No related tags found
1 merge request
!50
Feature/backend couchdb
Pipeline
#354289
passed
Nov 6, 2020
Stage: test
Changes
1
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
aas/backend/couchdb.py
+8
-5
8 additions, 5 deletions
aas/backend/couchdb.py
with
8 additions
and
5 deletions
aas/backend/couchdb.py
+
8
−
5
View file @
1a466d5c
...
...
@@ -342,7 +342,6 @@ class CouchDBObjectStore(model.AbstractObjectStore):
:raises CouchDBError: If error occur during the request to the CouchDB server (see `_do_request()` for details)
"""
logger
.
debug
(
"
Deleting object %s from CouchDB database ...
"
,
repr
(
x
))
# If x is not a CouchDBIdentifiable, retrieve x from the database to get the current couchdb_revision
rev
=
get_couchdb_revision
(
"
{}/{}/{}
"
.
format
(
self
.
url
,
self
.
database_name
,
self
.
_transform_id
(
x
.
identification
)))
...
...
@@ -352,18 +351,22 @@ class CouchDBObjectStore(model.AbstractObjectStore):
elif
safe_delete
:
raise
CouchDBConflictError
(
"
No CouchDBRevision found for the object
"
)
else
:
# If not safe_delete, fetch the current document revision from the database using a HEAD request and the
# ETag response header
try
:
logger
.
debug
(
"
fetching the current object revision for deletion ...
"
)
request
=
urllib
.
request
.
Request
(
"
{}/{}/{}
"
.
format
(
self
.
url
,
self
.
database_name
,
self
.
_transform_id
(
x
.
identification
)),
headers
=
{
'
Accept
'
:
'
application/json
'
})
current_data
=
CouchDBBackend
.
do_request
(
request
)
except
CouchDBServerError
as
e
:
headers
=
{
'
Accept
'
:
'
application/json
'
},
method
=
'
HEAD
'
)
opener
=
urllib
.
request
.
build_opener
(
urllib
.
request
.
HTTPBasicAuthHandler
(
_credentials_store
))
response
=
opener
.
open
(
request
)
rev
=
response
.
getheader
(
'
ETag
'
)[
1
:
-
1
]
except
urllib
.
error
.
HTTPError
as
e
:
if
e
.
code
==
404
:
raise
KeyError
(
"
No AAS object with id {} exists in CouchDB database
"
.
format
(
x
.
identification
))
\
from
e
raise
rev
=
current_data
[
'
_rev
'
]
request
=
urllib
.
request
.
Request
(
"
{}/{}/{}?rev={}
"
.
format
(
self
.
url
,
self
.
database_name
,
self
.
_transform_id
(
x
.
identification
),
rev
),
...
...
...
...
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
sign in
to comment