Skip to content

Commit 4f5c59d

Browse files
committedNov 3, 2014
design_create: Preparse if string
This parses a design document string into JSON (if it's not already a dict) and proceeds with normal handling. This lifts some restrictions when the input is a string. Change-Id: I5dbeb8d72756cf415f06ae178cf224f059f48118 Reviewed-on: http://review.couchbase.org/42365 Tested-by: Mark Nunberg <[email protected]> Reviewed-by: Volker Mische <[email protected]>
1 parent 5bc1096 commit 4f5c59d

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed
 

‎couchbase/bucketmanager.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,12 @@ def design_create(self, name, ddoc, use_devmode=True, syncwait=0):
137137
name = self._cb._mk_devmode(name, use_devmode)
138138

139139
fqname = "_design/{0}".format(name)
140-
if isinstance(ddoc, dict):
141-
ddoc = ddoc.copy()
142-
ddoc['_id'] = fqname
143-
ddoc = json.dumps(ddoc)
144-
else:
145-
if use_devmode:
146-
raise ArgumentError.pyexc("devmode can only be used "
147-
"with dict type design docs")
140+
if not isinstance(ddoc, dict):
141+
ddoc = json.loads(ddoc)
142+
143+
ddoc = ddoc.copy()
144+
ddoc['_id'] = fqname
145+
ddoc = json.dumps(ddoc)
148146

149147
existing = None
150148
if syncwait:

0 commit comments

Comments
 (0)