Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ARSnova Setup Tool
Manage
Activity
Members
Labels
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Privacy
Imprint
Contact
Snippets
Groups
Projects
Show more breadcrumbs
ARSnova
ARSnova Setup Tool
Commits
0632ae96
There was an error fetching the commit references. Please try again later.
Commit
0632ae96
authored
10 years ago
by
Daniel Gerhardt
Browse files
Options
Downloads
Patches
Plain Diff
Implement DELETE, do not require body for POST
parent
d4349bc4
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
couchconnection.py
+14
-2
14 additions, 2 deletions
couchconnection.py
with
14 additions
and
2 deletions
couchconnection.py
+
14
−
2
View file @
0632ae96
...
...
@@ -2,6 +2,7 @@ import httplib
import
base64
import
ConfigParser
import
io
import
json
class
CouchConnection
(
httplib
.
HTTPConnection
):
"""
docstring for CouchConnection
"""
...
...
@@ -20,11 +21,11 @@ class CouchConnection(httplib.HTTPConnection):
self
.
request
(
"
GET
"
,
path
,
""
,
header
)
return
self
.
getresponse
()
def
post
(
self
,
path
,
body
,
header
=
{}):
def
post
(
self
,
path
,
body
=
None
,
header
=
{}):
self
.
request
(
"
POST
"
,
path
,
body
,
header
)
return
self
.
getresponse
()
def
json_post
(
self
,
path
,
body
,
header
=
{}):
def
json_post
(
self
,
path
,
body
=
None
,
header
=
{}):
h
=
{
"
Content-Type
"
:
"
application/json
"
}
self
.
request
(
"
POST
"
,
path
,
body
,
dict
(
h
.
items
()
+
header
.
items
()))
return
self
.
getresponse
()
...
...
@@ -38,6 +39,17 @@ class CouchConnection(httplib.HTTPConnection):
self
.
request
(
"
PUT
"
,
path
,
body
,
dict
(
h
.
items
()
+
header
.
items
()))
return
self
.
getresponse
()
def
delete
(
self
,
path
,
body
=
None
,
header
=
{}):
self
.
request
(
"
GET
"
,
path
)
res
=
self
.
getresponse
()
doc
=
json
.
loads
(
res
.
read
())
if
"
_rev
"
in
doc
:
self
.
request
(
"
DELETE
"
,
path
+
"
?rev=
"
+
doc
[
"
_rev
"
],
body
,
header
)
res
=
self
.
getresponse
()
return
res
.
read
()
else
:
return
False
def
temp_view
(
self
,
path
,
body
,
header
=
{}):
return
self
.
json_post
(
path
+
"
/_temp_view
"
,
body
,
header
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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